Syntax errors

by: anselal, 9 years ago


At http://pythonprogramming.net/global-local-variables/?completed=/function-parameter-defaults-python-3-basics/

def example():
    print x # syntax error



You must be logged in to post. Please login or register an account.



Change it to
print(x)


In python 2.7, print was a statement, so you could do
print x
. In Python 3+, print is a function, so it needs the parenthesis.


-Harrison 9 years ago

You must be logged in to post. Please login or register an account.