Bird
0
0

Find the error in this nested conditional code:

medium📝 Debug Q14 of 15
Python - Conditional Statements
Find the error in this nested conditional code:
num = 5
if num > 0:
if num < 10:
print('Number is between 1 and 9')
AMissing colon after first if
BNo error, code is correct
CUsing print without parentheses
DIncorrect indentation of inner if and print
Step-by-Step Solution
Solution:
  1. Step 1: Check colons

    Both if statements have colons, so no missing colon error.
  2. Step 2: Check indentation

    Inner if and print are not indented under outer if, causing syntax error.
  3. Final Answer:

    Incorrect indentation of inner if and print -> Option D
  4. Quick Check:

    Nested blocks must be indented [OK]
Quick Trick: Indent nested if and its code properly [OK]
Common Mistakes:
MISTAKES
  • Forgetting to indent nested blocks
  • Confusing missing colon with indentation error
  • Assuming print syntax error without checking Python version

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes