← Python Roadmap
Home
11. Errors & Exception Handling
Common errors, try/except, defensive mindset
Goals:
Error types recognize karna
try
/
except
Safe handling pattern
1. Errors normal hain
SyntaxError
— typing/structure
NameError
— variable define nahi
TypeError
— galat type operation
ValueError
— type theek, value galat (jaise
int("abc")
)
IndexError
— list index bahar
Live practice 1 — try/except ValueError
except block chalna chahiye.
try: n = int("abc") print(n) except ValueError: print("Number likho, text nahi") print("Program crash nahi hua")
▶ Run Code
Live practice 2 — ZeroDivision
Safe divide.
a = 10 b = 0 try: print(a / b) except ZeroDivisionError: print("Zero se divide possible nahi")
▶ Run Code
☐
Mark complete
← Prev
Next →