Python is one of the most popular and widely used scripting languages. Many developers prefer to use Python as a scripting language because of its ease of use and its capability. You are here means you have come across an error message “missing parentheses in call to ‘print’” while running your Python program for a simple print statement.
You must be worried that it was working earlier but now suddenly starts throwing this unknown error message. It’s a little annoying if we get an error message for a simple statement that we have been using for a long time.
But don’t worry, go through this article thoroughly to understand why you are facing the “missing parentheses in call to ‘print’” error message for a simple print statement in Python and how to resolve this.
I got this error message for the following simple program.
# File: Hello.py
print "Welcome to Technolads!"
I got the following error message on my command prompt after executing the above program.
Let’s first try to understand the meaning of missing parentheses in the call to ‘print’ error message.
As you can see, it is clearly mentioned in the error message that parenthesis is missing from the print statement that you are using in your code.
Why you are getting missing parentheses in the call to ‘print’?
Two major reasons may result in the missing parentheses error message
Missing parentheses from the print statement in the code.
As mentioned in the error message you may have missed adding the parenthesis in the print statement. Please check your code thoroughly, and identify and fix the missing parentheses from the print statement.
The version of python
You may have got this error message because of a change in the version of the python. Because there is a change in the syntax of print statements in Python 2.x versions and Python 3.x versions.
If earlier you were using Python 2.x versions and now suddenly shifted to 3.x versions then you will face this error message.
In Python 2.x versions there is no parenthesis in the print statement as shown below.
print "Welcome to Technolads!"
In Python 3.x versions it’s mandatory to have parenthesis in the print statement as shown below
print ("Welcome to Technolads !")
How to resolve missing parentheses in a call to ‘print’?
Using the following two ways you can get rid of this error message. Let’s understand one by one.
Add parentheses in the print statement
Adding parenthesis is the easiest solution to get rid of this error message.
Add parenthesis in the print statement as shown below and re-run the code.
print("Welcome to Technolads!")
Your code will get executed successfully as shown below without any error message.
Change the version of python
You can always shift back to earlier 2.x versions of Python where you don’t have to use parenthesis in the print statement. But be careful, you may lose new important functionalities that are available in the latest version of Python. Make sure to download the required version of Python from the official site only.
Conclusion
We hope you got clear about the causes and possible solutions for the “missing parentheses in call to ‘print’” error message. You can get rid of this error message by adding parentheses in the print statement or by changing the version of Python. But shifting to the previous version is not recommended at all. We at Technolads recommend you to always use the latest version of Python while writing your code and get handy with the latest syntax of the print statement. Please mention your suggestions and experience of using the latest syntax in the comment section or you can reach out to us using the contact form.
Happy learning.