Bird
0
0

Identify the error in this input validation function:

medium📝 Debug Q6 of 15
Agentic AI - Agent Safety and Guardrails
Identify the error in this input validation function:
def check_input(data):
    if data == None:
        return False
    return True
ANo error, function is correct
BMissing return statement
CIncorrect indentation
DUsing '==' instead of 'is' to check None
Step-by-Step Solution
Solution:
  1. Step 1: Review None checking best practice

    In Python, 'is' should be used to check None, not '=='.
  2. Step 2: Identify why '==' is problematic

    '==' can cause unexpected behavior if __eq__ is overridden; 'is' checks identity safely.
  3. Final Answer:

    Using '==' instead of 'is' to check None -> Option D
  4. Quick Check:

    Check None with 'is' not '==' [OK]
Quick Trick: Use 'is None' to check None values [OK]
Common Mistakes:
  • Using '==' for None check
  • Thinking indentation is wrong
  • Assuming missing return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes