7.reverse


#1



Replace this line with your code.


#2

def reverse(word):

x = len(word)

while x > 0:
    return word[x-1]
    x -= 1

I'm not sure why it doesn't continue to loop round instead of just stopping with !. Help please


#3

What does return do?
Can a function return multiple times? How does that work out?


#4

I thought if it was within the while loop it would keep returning until x was 0


#5

Thanks for your advice!

I've managed to do it now by appending a list and then joining that but still feel there must be a more elegant way of achieving the aim


#6

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