Error Handling
A NameError comes up when you try to reference a variable that does not exist yet.
A TypeError occurs when you use an operator incorrectly.
A SyntaxError means that you broke Python's rules of spelling, grammar, and punctuation.
try:
result = 10/0
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("This always runs")
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopNext