Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q6 of 15
Python - For Loop
Find the error in this code snippet:
for i in range(5)
    print(i)
else:
    print('Done')
AMissing colon after for statement
BIndentation error in else block
Celse block cannot be used with for
DMissing parentheses in print
Step-by-Step Solution
Solution:
  1. Step 1: Check for syntax errors

    The for statement must end with a colon (:). Here, it is missing.
  2. Step 2: Verify other parts

    Indentation and print statements are correct. else can be used with for.
  3. Final Answer:

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

    For loops require colon at end [OK]
Quick Trick: Always put colon after for statement [OK]
Common Mistakes:
MISTAKES
  • Forgetting colon after for
  • Thinking else is invalid with for
  • Misreading indentation errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes