Editor settings

General settings

Save settings

Learn to program with Python

Missing parentheses #

In Python, parentheses are used to enclose arguments in function calls, define tuples, and group expressions. Forgetting to include or properly close parentheses can lead to syntax errors in your code. It's important to understand where parentheses are required and ensure they are used correctly to avoid such errors.

For example, if we run this code below in our editor:

print("Hello World"

The output of the program will be an error type SyntaxError, which tells us that there is something wrong with the syntax.

# Output:
File "main.py", line 1
    print("Hello World"
         ^
SyntaxError: '(' was never closed
The error message helps pinpoint the exact location of the error by indicating the file name and line number where the error was raised. This allows you to navigate to the specific part of your code that needs attention. In the example above, you can see that the error happened on line 1 in the file main.py

Exercise #

  • Fix the code by adding the necessary parentheses to resolve the syntax error.

Tests #

  • The program should run without an error
  • The program should print the message "Hello World!"
Output will be displayed here