Reverse


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096#


why does putting letters in line 5 work but when i put len(text) it doesnt? arent they basically the same thing?


def reverse(text):
    rev = ""
    letters = len(text)
    while letters > 0:
        rev += text[ letters -1 ]
        letters -= 1
    return rev
Replace this line with your code.


#2

because you decrease the value in letters:

letters -= 1

which means you go from high to lower index of text, while len(text) will stay the same length


#3

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