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 suddenly start throwing this unknown error message. It’s a little annoying if we get an error message for a simple statement that we are 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 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 call to ‘print’?
There are following two major reasons that 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 python. Because there is a change in the syntax of print statement in python 2.x versions and python 3.x versions.
If you were using python 2.x versions earlier and suddenly shifted to 3.x versions, 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 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 getting 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 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.
We hope you got clear about the causes and possible solutions for “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.