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

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

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

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