Reverse.Practice_Makes_Perfect


#1



Hey guys, I'm having a bit of trouble with this part of the exercise. I got the function to work for printing the statement, however, when I change it to a return statement it only returns one input in the string. Was wondering if I could get a clue (please do not tell me the answer). I appreciate it thanks!


#input a string and should print in reverse. 
def reverse(text): 
    j = len(text) - 1
    for i in range(len(text)):
        print text[-i + j],


#2

you need to return the result, which mean we need to store the result somewhere. Create a list or a string, and append to the list or string and after the for loop return the list or string

That should be help, but not too much of an answer. Good luck! If you keep struggling, i will help you further


#3

Still having a bit of confusion here. It's stupid really, I guess i'm not understanding the return function as well as I thought.


#4

When I append in the for loop it only returns the ['o'] in the for loop.


#5

wait, I think i got it. I had to have the return function OUTSIDE the loop. however, could you give me a reason as to why we have to do this in some cases.


#6

Wait, now i think i understand why it needs to be out side because my empty list is outside the for loop so i need to return it back into the empty list, therefore it needs to be in its bound.


#7

did you figure it out? If you need more help, post an updated version of your code


#8

I totally figured it out! Thanks!