Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q6 of 15
Python - Loop Control
Find the error in this code snippet:
for i in range(5):
    if i == 3
        continue
    print(i)
Arange function is used incorrectly
BMissing colon after if condition
Cprint statement is incorrectly indented
Dcontinue cannot be used inside for loop
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of if statement

    The if statement is missing a colon at the end of the condition line.
  2. Step 2: Validate other parts

    continue is valid inside for loops, print indentation is correct, range usage is correct.
  3. Final Answer:

    Missing colon after if condition -> Option B
  4. Quick Check:

    Syntax error due to missing colon [OK]
Quick Trick: If statements always need a colon at the end [OK]
Common Mistakes:
MISTAKES
  • Thinking continue is invalid in for loops
  • Misreading indentation errors
  • Assuming range usage is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes