7.Reverse


#1

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

Please guys, I can't find the error.
It was supposed to invert any string defined as input. I testes on Python 3 on my computer and it worked properly.


word = ""
palavra = []
def reverse(text):
    for indice in range(len(text)):
        word = text[-(indice+1)]
        palavra.append(word)
        outro = ''.join(palavra)
    return outro


#2

Put

word = ""
palavra = []

inside the function, right below the definition. They are global variables right now and will retain any word that the function appends (and not refresh for very call).


#3

How did you do thaaaat?!! Thank you so much!!


#4

Error messages say a lot about bugs. Especially python errors. I saw that in my tests, the result had the previous one in it and realized it's because word and palavra were outside.


#7