My code is not working as below, but I can't find the problem, is it because I use range?

def reverse(text):
    str = ""
    for i in range(len(text)-1,1):
        str += text[i]
    return str


maybe take a look at the documentation about range:

range can take 3 arguments (start, stop, step) see which ones you need in this exercise


I'm using range(start,stop)


but if the start value is higher then the stop value, you can't use the default of +1 steps. That doesn't work, you will need the third argument


You cannot use str as a variable. str is a reserved word. change it to string or another name and make sure you are looping through the entire length of the string. Use print statements to print out value of text[i] to make sure its printing the correct values.


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