7. reverse


def reverse(text):
    x = []
        for i in range(len(text)-1,0,-1):
        print text[i]
        return x
print reverse("abcdef")

I'm not sure why this won't work
This is the output:

7. reverse

a function ends the moment a return keyword is reached, so your function end in the first iteration of your loop, is this what you want?


You should put more attention to indentation. In Python this is very important.


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