Bird
0
0

Identify the problem in this code:

medium📝 Debug Q7 of 15
Python - Exception Handling Fundamentals
Identify the problem in this code:
try:
    print('Hello')
except:
    print('Error')
finally
    print('Done')
AMissing colon after finally
Bfinally block not allowed here
Cexcept block missing exception type
Dprint statements are invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check finally syntax

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

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

    Missing colon after finally -> Option A
  4. Quick Check:

    Finally must end with ':' [OK]
Quick Trick: Put ':' after finally to avoid syntax errors [OK]
Common Mistakes:
  • Omitting colon after finally
  • Thinking finally is optional syntax
  • Confusing except syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes