Daily Python
Day 11Python~35 min
Exceptions
try / except / else / finally
Track progress0/15 days
What you'll learn
tryexceptValueErrorZeroDivisionErrorraise
- Catch common errors without crashing
- Build a safe calculator with error handling
Lesson & examples
Read the code, then the explanation — try changing values before the project.
Handle division by zero
try:
num = int(input("Number: "))
print(10 / num)
except ZeroDivisionError:
print("Cannot divide by zero.")