DEV Community

pagarsach14
pagarsach14

Posted on

Exceptions versus Syntax Errorspython

Exceptions versus Syntax Errors
Syntax errors occur when the parser detects an incorrect statement. Observe the following example:

print( 0 / 0 ))
File "", line 1
print( 0 / 0 ))
^
SyntaxError: invalid syntax
The arrow indicates where the parser ran into the syntax error. In this example, there was one bracket too many. Remove it and run your code again:

print( 0 / 0)
Traceback (most recent call last):
File "", line 1, in
ZeroDivisionError: integer division or modulo by zero
summary this code some cases mostly use if you have need more detailed information then visit https://www.pythonslearning.com


Top comments (0)