7. Reverse! Stuck


#1




I spent too much time to solve this, but still stuck. If anyone could help me with my code, I'd be grateful.
it displays this error :

Traceback (most recent call last):
File "python", line 5, in
File "python", line 3, in reverse
TypeError: unsupported operand type(s) for -: 'int' and 'str'


Replace this line with your code. 
def reverse(text):
    for a in range(len(text)):
        text[a] = text[len(text)-1-a]
        return text
print reverse("1234")


#2

The operator - (minus) isn't defined for int and string

You can't do:

5 - 'banana'

However, the code you posted does not produce that error message. You've posted an error message that came from running some other code.


#3

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