Help with Reverse!


Oops, try again. Your function fails on reverse("Python!"). It returns "['!', 'n', 'o', 'h', 't', 'y', 'P']" when it should return "!nohtyP".

Why won't the .join() work?

def reverse(text):
    for i in range(len(text)-1,-1,-1):
        ' '.join(output)
    return output


It's working plenty, but what do you do with its result?
Also, how many times do you need to use join?


I just realized that the .join() should either be assigned to a variable or returned; else it won't work quite as expected.
Plus yes, I should intend the statement in such a way it runs just once. :slight_smile:
return ''.join(output)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.