Write a function to repeat M characters of a string N times


Topic: Write a function to repeat M characters of a string N times

Solution

def multTimes(str, m, n):
    front_len = m
    if front_len > len(str):
        front_len = len(str)
    front = str[:front_len]
    result = ''
    for i in range(n):
        result = result + front
    return result
print (multTimes('Hello', 3, 7))



List all Python Programs