7。 reverse


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096#
<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>
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.

```python

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

<do not remove the three backticks above>

#2
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.


#3

Do you mean to write,

    reversetext += n

?


#4

Yes, like string append


#5

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