Bird
0
0

Find the error in this code:

medium📝 Debug Q6 of 15
Python - Loop Control
Find the error in this code:
for i in range(5)
    if i == 3:
        break
    print(i)
Arange should be range(1,5)
BWrong indentation of print
Cbreak cannot be used in for loop
DMissing colon after for statement
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of for loop

    Python requires a colon ':' after for statement.
  2. Step 2: Identify missing colon

    Code misses colon after 'for i in range(5)', causing syntax error.
  3. Final Answer:

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

    Syntax requires colon after for [OK]
Quick Trick: Always put ':' after for loops [OK]
Common Mistakes:
MISTAKES
  • Forgets colon
  • Wrong indentation
  • Misusing break
  • Wrong range arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes