Reverse


#1

This code works....it does print out "Python!" in reverse. Codecademy doesn't seem to thing so though.....

def reverse(text):
    string = str(text)
    count = 1
    for letter in string:
        if count <= len(string):
            print string[len(string)-count],
            count += 1
print reverse('Python!')

Any suggestions??


7. Reverse
#2

You should return the result , not print it

try this:

def reverse(text):
    result = ""
    index = len(text) - 1
    while(index >= 0):
        result += text[index]
        index -= 1
    return result

#3

it needs the capital P aswell


#4

The exercise wants you to return the reversed string, you don't meet this requirement. Make a string in which you store the reversed result so you can return it after the reversion is done


#5

Thanks guys! I figured it out.