[solved] SyntaxError: Missing parentheses in call to ‘print’ in Python

A hand holding the Python logo
Photo by RealToughCandy.com, source: Pexels

🚫 SyntaxError: Missing parentheses in call to ‘print’

The error “SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(…)?” in Python happens when you use an old-style print statement (e.g., print 'some value') in Python 3.

This long error looks like this:


File /dwd/sandbox/test.py, line 1
  print 'some text here'
  ^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

As the error explains, from Python 3, you must call the print() function:


# 🚫 Python 3 raises SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
print 'some text here'

# ✅ Correct
print('some text here')

You might get this error if you're running an old code by your Python 3 interpreter or copying a code snippet from an old post on Stackoverflow.

How to fix the "SyntaxError: Missing parentheses in call to 'print'"?

All you need to do is to call print() with your string literal(s) as its argument(s) - and do the same to every old-style print statement in your code.

The print() function is much more robust than its predecessor. Python 3 enables you to adjust the print() function's behavior based on your requirements.

For instance, to print a list of text values separated by a character (e.g., a space or comma), you can pass them as multiple arguments to the print() function:


# ✅ Using print() with multiple arguments:

price = 49.99
print('The value is', price)
# output: The value is 49.99

As you can see, the arguments are separated by whitespace. To change the delimiter, you can use the sep keyword argument:


print('banana', 'apple', 'orange', sep=', ')
# output: banana, apple, orange

Python 3 takes the dynamic text generation to a new level by providing formatted string literals (a.k.a f-strings) and the print() function.

One of the benefits of f-strings is concatenating values of different types (e.g., integers and strings) without having to cast them to string value. You create an f-string by prefixing it with f or F and writing expressions inside curly braces ({}):


user = {
    'name': 'John',
    'score': 75
}

print(f'User: {user[name]}, Score: {user[score]}')
# output: User: John, Score: 75

In python 2.7, you'd have to use the + operator or printf-style formatting.

Please note that f-string was added to Python from version 3.6. For older versions, check out the str.format() function.

And that's how you fix the "SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?" error in Python 3.

Alright, I think it does it. I hope this quick guide helped you solve your problem.

Thanks for reading.

Author photo

Hey 👋 I'm a software engineer, an author, and an open-source contributor. I enjoy helping people (including myself) decode the complex side of technology. I share my findings on Twitter: @lavary_

If you read this far, you can tweet to the author to show them you care. Tweet a Thanks

In this article:

Disclaimer: This post might contain affiliate links. I might receive a commission if a purchase is made. However, it doesn’t change the cost you’ll pay.