About Reverse


#1



Reverse


It says my code has the following error:Your code looks a bit off--it threw a "string index out of range" error. Check the Hint if you need help!


def reverse(text):
    new=''
    for a in range(0,len(text)+1):
        new+=text[len(text)-a]
    return new


#2

Have you had a look at which indexes you're using for text? What you'd do is print them out just before using them, and check whether they're valid. They're probably not, judging by the error, and once you've found what's wrong about the index you can reconsider how you went about computing it


#3

The index I use for text is len(text)-a and a is in range(0,len(text)+1) in the loop. I don't know what's wrong..


#4

Print them out and see for yourself if they're actually what they should be


#5

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