7。 reverse



The error code is File "python", line 6
SyntaxError: can't assign to function call

Oops, try again. Did you create a function called reverse? Your code threw a "global name 'reverse' is not defined" error.

def reverse(text):
    reversetext = ''
    while len(text)> 0:
        n = text[len(text)-1: len(text)]
        reversetext & str(n)
        len(text) -= 1
    return reversetext


def reverse(text):
    reversetext = ''
    i = len(text)
    while i> 0:
        n = text[len(text)-1: len(text)]
        reversetext & n
        i -= 1
    return reversetext

I changed the code a bit and got another error message:

Oops, try again. Does your reverse function take exactly one argument (a string)? Your code threw a "unsupported operand type(s) for &: 'str' and 'str'" error.


Do you mean to write,

    reversetext += n



Yes, like string append


Wow, it worked now!!! Thanks a lot!