[Reverse] Alternative approach works in CA but I'm getting Syntax errors elsewhere


#1



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


This validates correctly on Codecademy, but won't run on another IDE (repl.it). Is there something wrong with this?


Also I took a different approach than most of the other solutions. Is mine less efficient? Is there anything that is not pythonic?
Maybe my solution will help someone else.


def reverse(text):
    r = len(text)  #find the length of text
    newtext = ''   #sets up as string
    while r > 0:
        newtext = newtext+text[r-1]
        r -= 1
    return newtext
        
print reverse('Python!')


#2

By the way, I get SyntaxError: invalid syntax (, line 9). I get this in repl.it and pythontutor .


#3

in python3, print is update from a keyword to a function call, so you need parentheses:

print(reverse('Python!'))

#4

Oh my gosh, I should have known. Thanks so much!


#5