Practice makes perfect: reverse


#1




So I know this only part of the solution. I could look at some of the other posts that have the answers, at how to write the code differently to get the answer, but I wanna know what I could do further to make this code work. (i know its probably not the simplest solution) I honestly dont know where to go from here to make the list print reverse without using reversed or the [::-1]


def reverse(text):
    lst = []
    word = str(text)
    for s in word:
        lst.append(s)
        
    return lst


#2

You are almost there, but i don't get what are you doing here

anyway the for loop goes straight, you have to think for something different.


#3

I solved this another way, but I would still like to try and solve it the way i originally set out to do. Just to learn better/different ways. I think my logic was making sure the argument would always be a string. Ive been home today all day practicing Python and my brain might be a little fried at this point haha. So I should take that out then im guessing?


#4

Yes. text is already a string; no need to convert it.


#6

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