Bird
Raised Fist0

Find the error in this code:

medium📝 Debug Q6 of Q15
Python - Exception Handling Fundamentals
Find the error in this code:
try
    x = 10 / 2
except ZeroDivisionError:
    print('Error')
AMissing except block
BWrong exception name
CMissing colon after try
DDivision by zero error
Step-by-Step Solution
Solution:
  1. Step 1: Check try syntax

    Python requires a colon ':' after 'try' keyword.
  2. Step 2: Identify missing colon

    Code has 'try' without colon, causing syntax error.
  3. Final Answer:

    Missing colon after try -> Option C
  4. Quick Check:

    Try must end with ':' [OK]
Quick Trick: Always put ':' after try and except [OK]
Common Mistakes:
MISTAKES
  • Forgetting colon after try or except
  • Confusing exception names
  • Assuming division error always occurs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes