Python Forum

Full Version: SyntaxError
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Started in Python yesterday. Why this code returns "SyntaxError: Missing parentheses in call to 'print'"
On the Forum interpreter it runs with no errors.
Thank you.

>>> for letter in 'Python':     # First Example
   print 'Current Letter :', letter

fruits = ['banana', 'apple',  'mango']
for fruit in fruits:        # Second Example
   print 'Current fruit :', fruit

print "Good bye!"

>>> 
Because you are missing parentheses in call to 'print'
Print needs parentheses, like this:

Quote:print("Hello world")
(Aug-30-2017, 03:54 AM)woehl Wrote: [ -> ]
print "Good bye!"

The print statement without parentheses is the syntax of Python 2.
You have to use parentheses in Python 3.x.

print("Good bye!")
(Aug-30-2017, 03:54 AM)woehl Wrote: [ -> ]Started in Python yesterday

Update your learning source to Python 3.