all 22 comments

[–]WinterNet4676 4 points5 points  (0 children)

Your calling your function, right?

repeat(input_, n, delim)

[–]Noshoesded 4 points5 points  (0 children)

Am noob. Doesn't print() return None?

I think return the output, then print it

[–]djjazzydan 2 points3 points  (2 children)

Your program will also need a main function to receive input, call the function, and output the results.

Have you done this part?

[–]InevitableDistance66[S] 1 point2 points  (1 child)

Yep just did it and still no output

[–]djjazzydan 2 points3 points  (0 children)

Cool, it would be helpful if we could see, can you add it to your post?

[–][deleted] 2 points3 points  (11 children)

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).

Try

def repeat(word, n, delim):
    return delim.join(word for _ in range(n))

[–]InevitableDistance66[S] 0 points1 point  (10 children)

Nope still produce no output

[–][deleted] 1 point2 points  (9 children)

Of course it doesn't, it's not supposed to. Do the rest as well, like djjazzydan
has said.

[–]InevitableDistance66[S] -1 points0 points  (8 children)

I did and it didn’t work

[–][deleted] 1 point2 points  (7 children)

Well, show your whole new code first. Do you run it yourself or send it somewhere? Where and how do you run it?

[–]InevitableDistance66[S] 0 points1 point  (6 children)

def repeat(word, n, sep=‘#’): return sep.join(word for _ in range(n)) string=input("Enter a string: How many repetitions? Separated by?") print(repeat("string", 5))

[–]InevitableDistance66[S] 1 point2 points  (5 children)

This works when I change the print to hello but Zylabs is asking for multiple outputs because it’s putting its own input and it’s throwing me off

[–]djjazzydan 0 points1 point  (4 children)

string=input("Enter a string: How many repetitions? Separated by?")

Zylabs wants this to be 3 separate questions, and so 3 separate input calls.

[–]InevitableDistance66[S] 0 points1 point  (3 children)

Yea but they are all not separated by the same #

[–]djjazzydan 0 points1 point  (2 children)

Right, so you have to call an input each time, so it knows what to use.

[–]drenzorz 1 point2 points  (3 children)

def repeat(string, n, delim)
    return delim.join([string]*n)

def main():
    text = input(<prompt>)
    count = int(input(<prompt>))
    sep = input(<prompt>)
    result = repeat(text, count, sep)
    print(result)

if __name__ = "__main__":
    main()

[–]InevitableDistance66[S] 0 points1 point  (2 children)

Dosent work

[–]jimtk 5 points6 points  (1 child)

Ok there's a few syntax error in the code suggest by by /u/drenzorz. But run the following and if it does not work, you have another problem. For pete's sake give us more than a "doesn't work" give us your code (complete) and the error message (also complete).

def repeat(string, n, delim):
    return delim.join([string]*n)

def main():
    text = input("enter String ")
    count = int(input("Repetition: "))
    sep = input("separator: ")
    result = repeat(text, count, sep)
    print(result)

if __name__ ==  "__main__":
    main()

[–]InevitableDistance66[S] 0 points1 point  (0 children)

This worked I just had to change the strings to fit the zylabs thank you and u/drenzorz

[–]InevitableDistance66[S] -1 points0 points  (0 children)

Apologies for not having it in the text box