Bird
0
0

This Lambda function code causes an error when triggered:

medium📝 Debug Q14 of 15
AWS - Lambda
This Lambda function code causes an error when triggered:
def handler(event, context):
    return event['data'] * 3

What is the likely cause?
AThe function is missing the context parameter.
BThe event dictionary does not have the 'data' key.
CThe return statement syntax is incorrect.
DLambda functions cannot multiply values.
Step-by-Step Solution
Solution:
  1. Step 1: Identify cause of error in code

    The function tries to access event['data'], which may not exist.
  2. Step 2: Understand error from missing key

    If 'data' key is missing in event, a KeyError occurs causing the function to fail.
  3. Final Answer:

    The event dictionary does not have the 'data' key. -> Option B
  4. Quick Check:

    Missing event key causes error = B [OK]
Quick Trick: Check if event keys exist before using them [OK]
Common Mistakes:
  • Assuming context parameter missing causes error
  • Thinking return syntax is wrong
  • Believing Lambda cannot do arithmetic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes