If you are very new to Python Programming and trying to run your .py file in the command line (or terminal) and you see the error "SyntaxError: '(' was never closed", well then you have look at the error text and grab more details from it.
How to know which line has the issue?
When you run your Python code and it generates an error you can a traceback printed out in the console which contains the details of the error.
Let's understand this with a simple example.
example.py
print("Hello World"
When I run this example.py file in the terminal I get the below traceback
1. % python3 example.py
2. File "/Users/c2ctech/Desktop/example.py", line 1
3. print("Hello, World!"
4. ^
5. SyntaxError: '(' was never closed
There are a few important things to note here, at line number 2, you will see which file had an error and at what line. Note, we are getting this error on line 1.
Line number 3 highlights exactly at what statement the error is and line 5 tells us that it is a SyntaxError.
So you read the error as "There is a SyntaxError on line 1 of my example.py file"
How to fix this error
The fix is self-explanatory, but one could be very new to programming, so let me elaborate, every programming language has a syntax, a structure that you should follow, if it is not followed correctly, you get errors when you run your code.
The print function in Python needs to be enclosed within parenthesis, If you miss the closing braces, you will get this error we are dealing with here.
The fix is simple, make sure to close the print function with a closing parenthesis.
print("Hello World")

Have Questions? Post them here!
- Create a Zip file using Java Code programmatically
- Eclipse : A java Runtime Environment (JRE) or Java Development kit (JDK) must be available
- How to Sort a LinkedList in Java
- Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver
- How to declare and initialize Array in Java Programming
- [Fix] java: integer number too large compilation error
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Reading .xls and .xlsx Excel file using Apache POI Java Library
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- How to get Client IP address using Java Code Example
- Truncate table using Java JDBC Example
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- How to get file path in Idea IntelliJ IDE
- Java Generics explained with simple definition and examples
- Java SE 8 Update 301 available with various bug fixes and security improvements
- Java: Collect Stream as ArrayList or LinkedList
- Java JDBC Connection with PostgreSQL Driver Example
- How to check if Java main thread is alive
- How to fix Java nio NoSuchFileException wile reading a file
- Java 8+ get Day of the Week Examples with LocalDateTime, DateTime, ZonalDateTime and Instant classes
- Ways to Convert Integer or int to Long in Java
- [Java] How to throws Exception using Functional Interface and Lambda code
- [Fix] Spring Boot: mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- Java: The value of the local variable string is not used
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- How to exit from nano command - Linux
- Convert Java Object to XML using Jackson Library - Java
- Android App Showing Two Toolbars Issue fix - Android
- What is macOS Ventura? - MacOS
- [Tutorial] Write And Run Python Code In Notepad++ Editor - NotepadPlusPlus
- Maven Eclipse (M2e) No archetypes currently available - Java
- How to connect AirPods to Mac - MacOS
- Install Node on Mac Ventura 13 - MacOS