What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?
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:
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:
In Python 3, print is a function, hence parentheses are mandatory:
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:
Embracing advanced print functionality in Python 3
Python 3's print function supports multiple values, custom separators, and custom end-of-line characters:
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: 
- 
Redirect output to different streams: 
Troubleshoot common mistakes
Be aware of frequently encountered mistakes:
- 
Omitting parentheses entirely: 
- 
Mixing Python 2 and 3 syntax: 
In order to avoid the above, remember to use parentheses and remember - Python 3 prioritizes clarity.
Was this article helpful?
