Bird
0
0

Which of the following is the correct syntax to check if the string 'apple' is NOT in the list fruits?

easy📝 Syntax Q12 of 15
Python - Operators and Expression Evaluation
Which of the following is the correct syntax to check if the string 'apple' is NOT in the list fruits?
Aif 'apple' not in fruits:
Bif 'apple' not fruits:
Cif not 'apple' fruits:
Dif 'apple' !in fruits:
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct syntax for not in

    The correct syntax to check absence is value not in collection.
  2. Step 2: Evaluate each option

    if 'apple' not in fruits: matches correct syntax. if 'apple' not fruits: misses in. if not 'apple' fruits: misses in. if 'apple' !in fruits: uses invalid operator !in.
  3. Final Answer:

    if 'apple' not in fruits: -> Option A
  4. Quick Check:

    Use not in as two words [OK]
Quick Trick: Use not in as two words, no symbols [OK]
Common Mistakes:
MISTAKES
  • Writing !in instead of not in
  • Omitting in after not
  • Using not 'value' in which is valid but less clear

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes