In: Computer Science
def repeat(string, n, delim)
that returns the string string repeated n times, separated by the string delim. For example repeat(“ho”, 3, “,”) returns “ho, ho, ho”.
keep it simple.Python
Python code:
#defining function repeat
def repeat(string,n,delim):
#creating a list containing string for n
times
lis=[string for i in range(n)]
#joining the list with delim between each
element in the list and returning it
return delim.join(lis)
#defining main function
def main():
#calling repeat function and printing the
result
print(repeat("ho",3,","))
if __name__ == "__main__":
#calling main function
main()
Screenshot:
Output: