Bird
0
0

What is wrong with this code snippet?

medium📝 Debug Q7 of 15
Python - For Loop
What is wrong with this code snippet?
for i in range(5):
print(i)
Arange(5) is incorrect
Bprint statement is not indented
CMissing parentheses in print
DVariable i is not declared
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation rules

    Python requires the code inside the loop to be indented.
  2. Step 2: Identify indentation error

    print(i) is not indented, so Python will raise an IndentationError.
  3. Final Answer:

    print statement is not indented -> Option B
  4. Quick Check:

    Loop body must be indented [OK]
Quick Trick: Indent loop body code properly [OK]
Common Mistakes:
MISTAKES
  • Not indenting loop body
  • Misusing print syntax
  • Wrong range usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes