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 -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

jquery - jqGrid update specific column data with out refreshing the entire column? -