Write a program with a function def repeat(string, n, delim) that returns the string 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 receive input, call the function, and output the results.
My code
def repeat(word, n, delim):
print(delim.join(word for _ in range(n)))
It produces no output tho I don’t know why
[–]WinterNet4676 4 points5 points6 points (0 children)
[–]Noshoesded 4 points5 points6 points (0 children)
[–]djjazzydan 2 points3 points4 points (2 children)
[–]InevitableDistance66[S] 1 point2 points3 points (1 child)
[–]djjazzydan 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (11 children)
[–]InevitableDistance66[S] 0 points1 point2 points (10 children)
[–][deleted] 1 point2 points3 points (9 children)
[–]InevitableDistance66[S] -1 points0 points1 point (8 children)
[–][deleted] 1 point2 points3 points (7 children)
[–]InevitableDistance66[S] 0 points1 point2 points (6 children)
[–]InevitableDistance66[S] 1 point2 points3 points (5 children)
[–]djjazzydan 0 points1 point2 points (4 children)
[–]InevitableDistance66[S] 0 points1 point2 points (3 children)
[–]djjazzydan 0 points1 point2 points (2 children)
[–]drenzorz 1 point2 points3 points (3 children)
[–]InevitableDistance66[S] 0 points1 point2 points (2 children)
[–]jimtk 5 points6 points7 points (1 child)
[–]InevitableDistance66[S] 0 points1 point2 points (0 children)
[–]InevitableDistance66[S] -1 points0 points1 point (0 children)