Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q7 of 15
Python - Basics and Execution Environment
Find the error in this code snippet:
if true:
    print('Yes')
      print('No')
ASecond print is over-indented
BMissing colon after if
CFirst print should be indented more
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation levels inside if block

    All statements inside the if block must have the same indentation level.
  2. Step 2: Identify inconsistent indentation

    The second print is indented more than the first, causing an indentation error.
  3. Final Answer:

    Second print is over-indented -> Option A
  4. Quick Check:

    Indentation must be consistent inside blocks [OK]
Quick Trick: Keep all block lines equally indented [OK]
Common Mistakes:
MISTAKES
  • Indenting some lines more than others
  • Ignoring indentation errors
  • Assuming Python ignores extra spaces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes