Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q14 of 15
Python - Operators and Expression Evaluation
Find the error in this code snippet:
items = ['pen', 'pencil', 'eraser']
if 'pen' not items:
    print('Pen is missing')
AIncorrect print statement syntax
BWrong list name
CMissing <code>in</code> after <code>not</code>
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check the membership syntax

    The correct syntax for checking absence is value not in collection. The code misses in after not.
  2. Step 2: Verify other parts

    List name and print statement are correct. The only error is missing in.
  3. Final Answer:

    Missing in after not -> Option C
  4. Quick Check:

    Use not in together [OK]
Quick Trick: Always write not in together [OK]
Common Mistakes:
MISTAKES
  • Writing not items instead of not in items
  • Forgetting in keyword
  • Assuming not alone checks membership

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes