Explain Codes LogoExplain Codes Logo

What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?

python
python-3
print-function
python-2-to-python-3
Alex KataevbyAlex Kataev·Mar 10, 2025
TLDR

If you're seeing the message SyntaxError: Missing parentheses in call to 'print', it means you're using Python 2-style print without parentheses in Python 3. The print in Python 3 is a function, hence requires parentheses:

print("The cake is a lie!") # Portal reference, anyone?

Contrarily, omitting parentheses while writing scripts in Python 2 is fine, but doing so will throw an error in Python 3.

Understand the error: Transition and compatibility

Migrating Python 2 to Python 3 requires adaptation to the fact that print has changed from a statement to a function call. This transition introduces flexibility but necessitates modifications to existing Python 2 code.

Python 2 vs. Python 3: print syntax

In Python 2, the syntax for print statement is:

# Python 2 syntax print "Stay awhile and listen!" # Say hi to Deckard Cain

In Python 3, print is a function, hence parentheses are mandatory:

# Python 3 syntax print("In soviet Russia, code debugs you!") # Yakov Smirnoff approves

Making Python 2 code compatible with Python 3

To make your Python 2 code forward-compatible, use from __future__ import print_function at the top:

# Compatible with both Python 2 and 3 from __future__ import print_function print("Look ma, no hands!") # Learn to juggle with Python

Embracing advanced print functionality in Python 3

Python 3's print function supports multiple values, custom separators, and custom end-of-line characters:

print("Hello", "World", sep=", ", end="!\n") # So much functionality, so little time

Decoding error messages: Python 3.4.2 and beyond

From Python 3.4.2 onwards, lack of parentheses in print will raise SyntaxError. Post Python 3.6.3, error messages pertaining to the older Python 2.x syntax were made more user-friendly.

Additional points: Python 3's advanced functionality

Python 3's print function exemplifies Python's tenets of location independence and flexibility.

  • Argument unpacking:

    # Python 3 words = ["Winter", "is", "coming"] print(*words, sep=' ') # A Jon Snow approved one-liner
  • Redirect output to different streams:

    # Python 3 import sys print("There has been an error!", file=sys.stderr) # Now the console can share our despair

Troubleshoot common mistakes

Be aware of frequently encountered mistakes:

  • Omitting parentheses entirely:

    # Python 3 print "Dang it, I forgot the parentheses." # Easy now, tiger!
  • Mixing Python 2 and 3 syntax:

    # Python 3 print "Am", "I", "still,", "or", "was", "I", "ever?", # Existential Crisis: Check ✔️

In order to avoid the above, remember to use parentheses and remember - Python 3 prioritizes clarity.