Back to Lesson

ZeroDivisionError

Write a try/except block to catch a division by zero error.

Instructions

  • Open a
    try:
    block and try to print
    10 / 0
    .
  • Add an
    except ZeroDivisionError:
    block.
  • Print
    "Cannot divide by zero"
    in the except block.
main.py
main.py