Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError
#1
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!"

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

Quote:print("Hello world")
Reply
#3
(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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020