Bird
0
0

Identify the error in this personal assistant agent code snippet:

medium📝 Debug Q14 of 15
Agentic AI - Real-World Agent Applications
Identify the error in this personal assistant agent code snippet:
skills = {'time': lambda: '12:00 PM'}
response = skills.time()
print(response)
ADictionary keys cannot be strings
BLambda function syntax is incorrect
Cskills.time() should be skills['time']()
DMissing parentheses in print statement
Step-by-Step Solution
Solution:
  1. Step 1: Check dictionary access method

    Dictionary keys must be accessed with brackets and quotes, not dot notation.
  2. Step 2: Correct the function call

    Use skills['time']() to call the lambda function properly.
  3. Final Answer:

    skills.time() should be skills['time']() -> Option C
  4. Quick Check:

    Access dict keys with brackets [OK]
Quick Trick: Use brackets to access dictionary keys, not dot [OK]
Common Mistakes:
  • Using dot notation for dict keys
  • Misunderstanding lambda syntax
  • Forgetting parentheses in print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes