Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q6 of 15
Python - Exception Handling Fundamentals
Find the error in this code snippet:
try:
    print(10 / 0)
except ZeroDivisionError, e:
    print('Error:', e)
AMissing finally block
BSyntax error in except clause
CNo error, code runs fine
DZeroDivisionError not caught
Step-by-Step Solution
Solution:
  1. Step 1: Review except syntax

    Python 3 uses 'except Exception as e:', not comma syntax.
  2. Step 2: Identify syntax error

    Using comma causes syntax error in Python 3.
  3. Final Answer:

    Syntax error in except clause -> Option B
  4. Quick Check:

    Use 'as' keyword in except clause [OK]
Quick Trick: Use 'except Exception as e:' syntax in Python 3 [OK]
Common Mistakes:
  • Using comma instead of 'as'
  • Ignoring syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes