1. Syntax Error
Example:
print("Hello, world!"
2. IndentationError
Example:
if True:
print("Indentation error")
Explanation: Python relies on indentation to define block structures. The print
statement is not properly indented under the if
statement, leading to an indentation error.
3.NameError
Example:
x = 5
print(y)
Explanation: The variable y
is not defined before trying to print it, resulting in a NameError.
It’s worth noting that the examples provided are intentionally incorrect to demonstrate the specific types of errors. In practice, understanding and fixing errors is an integral part of the development process. Python error messages typically provide helpful information about the nature and location of the error, making it easier to troubleshoot and correct issues.