This question already has an answer here:
Why do I receive a syntax error when printing a string in Python 3?
>>> print "hello World"
File "<stdin>", line 1
print "hello World"
^
SyntaxError: invalid syntax
This question already has an answer here:
Why do I receive a syntax error when printing a string in Python 3?
>>> print "hello World"
File "<stdin>", line 1
print "hello World"
^
SyntaxError: invalid syntax
It looks like you're using Python 3. In Python 3, print has been changed to a method instead of a statement. Try this:
You have to use brackets with print:
It looks like you're using Python 3.0, in which print has turned into a callable function rather than a statement.
In Python 3, you must do
print('some code')
. This is because in Python 3 it has become a function. If you must, you can use your Python 2 code and convert it to Python 3 code using2to3
- it is a great built-in program which comes with Python. For more, see Python 2to3 - Convert your Python 2 to Python 3 automatically!.In Python 3, it's
print("something")
, notprint "something"
.In Python 3.0,
print
is a regular function that requires ():