5 reverse This is confusing


#1



15 Reverse Practice makes perfect


Oops, try again. Does your reverse function take exactly one argument (a string)? Your code threw a "expected a character buffer object" error.


Please help me and thank you so much !


def reverse(text):
    str(text)
    letters=""
    n=len(text)-1
    while n >=0:
        print n
        letters+=str(str(text).index(n))
        n-=1
        print letters
    return letters


#2

Just assume that text will always be in string so all those str() can be removed.

Next:

This line. Why not just use the index concept you've learned throughout the course and just do letters += text[n]? So much simpler, right?


#3

Thank you!!! Yeah it is so much easier :slight_smile:


#4

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