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 -

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

sql - Error using the DATEDIFF syntax -