Bird
0
0

This Python Lambda handler code causes an error:

medium📝 Debug Q6 of 15
AWS - Lambda
This Python Lambda handler code causes an error:
def handler(event, context):
    return event['value'] + 5

What is the likely cause?
AContext object is required for addition
BMissing return statement
CLambda does not support addition
D'value' is missing or not a number in event
Step-by-Step Solution
Solution:
  1. Step 1: Check event dictionary access and type

    If 'value' key is missing or its value is not a number, adding 5 causes an error.
  2. Step 2: Eliminate other options

    Return statement exists; context is not used for addition; Lambda supports addition.
  3. Final Answer:

    'value' is missing or not a number in event -> Option D
  4. Quick Check:

    Type or missing key causes error [OK]
Quick Trick: Check event keys and types before operations [OK]
Common Mistakes:
  • Ignoring missing keys
  • Assuming context affects arithmetic
  • Thinking Lambda disallows addition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes