Write a function called repl that accepts a string and a number of repetitions as parameters and returns the string concatenated that many times. For example, the call repl('hello', 3) should return 'hellohellohello'. If the number of repetitions is zero or less, the function should return an empty string. Do not use the string * operator in your solution; use the concatenation operator.
Sample output:
hello -> hellohellohello
def repl(str, rep):
if rep <= 0:
print("Empty String")
return (str * rep)
print(repl(str(input("Enter the string: ")), int(input("Enter the number of repetitions: "))))
Comments
Leave a comment