Syntax errors
When the proper syntax of the language is not followed then a syntax error is thrown.
Example
Python3
# initialize the amount variable amount = 10000 # check that You are eligible to # purchase Dsa Self Paced or not if (amount> 2999 ) print ( "You are eligible to purchase Dsa Self Paced" ) |
Output:
It returns a syntax error message because after the if statement a colon: is missing. We can fix this by writing the correct syntax.
Errors and Exceptions in Python
Errors are the problems in a program due to which the program will stop the execution. On the other hand, exceptions are raised when some internal events occur which changes the normal flow of the program.
Two types of Error occurs in python.
- Syntax errors
- Logical errors (Exceptions)