Bird
0
0

Identify the error in this Lambda function code:

medium📝 Debug Q6 of 15
AWS - Lambda
Identify the error in this Lambda function code:
def handler(event, context):
    print(event['message'])
    return message
AVariable 'message' is not defined before return
BMissing event parameter in function
CContext parameter is not used
DPrint statement syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Check variable usage

    The function prints event['message'] but returns 'message' which is undefined.
  2. Step 2: Identify the error

    Returning 'message' causes a NameError because it is not assigned.
  3. Final Answer:

    Variable 'message' is not defined before return -> Option A
  4. Quick Check:

    Undefined variable in return causes error [OK]
Quick Trick: Return variables only after defining them [OK]
Common Mistakes:
  • Ignoring undefined variable errors
  • Confusing print with return
  • Assuming unused parameters cause errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes