Question: Write a function def repeat ( string , n , delim ) that returns the string repeated n times, separated by the string delim (

Write a function def repeat(string, n, delim) that returns the string repeated n times, separated by the string delim (ex. space, ?, #, etc).
Ex: If the input is:
Enter a string: hello How many repetitions? 5 Separated by? #
then the output is:
hello#hello#hello#hello#hello
Your program will also need a main() function to
get input of the string, repetitions, and delimiter and
call the function, and
prints the results.
Ex: If the input is:
Enter a string: world How many repetitions? 3 Separated by? $
then the output is:
world$world$world

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!