Multiplying Strings in Python -


given string , non-negative int n, return larger string n copies of original string.

string_times('hi', 2) → 'hihi' string_times('hi', 3) → 'hihihi' string_times('hi', 1) → 'hi' 

def string_times(string, times):     return string*times 

any sequence in python (of string example) can replicated multiplying sequence integer. although careful around numpy arrays, perform multiplication on every item in array.


Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

utf 8 - split utf-8 string into bytes in python -