Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q14 of 15
Python - While Loop

Find the error in this code snippet:

i = 1
while i < 5
    print(i)
    i += 1
AMissing colon after while condition
BVariable i is not initialized
CIndentation error in print statement
DInfinite loop because i never changes
Step-by-Step Solution
Solution:
  1. Step 1: Check while loop syntax

    The while line must end with a colon (:).
  2. Step 2: Identify the missing colon

    The code misses ':' after 'while i < 5', causing syntax error.
  3. Final Answer:

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

    While line needs colon [OK]
Quick Trick: Always put colon after while condition [OK]
Common Mistakes:
MISTAKES
  • Forgetting colon after while
  • Misindenting inside loop
  • Not updating loop variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes