mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-12 10:00:39 -04:00
1.2 KiB
1.2 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 65823bbbdb4eaa4f9d20a0fb | Step 17 | 20 | step-17 |
--description--
In the total_expenses function, you'll now integrate a lambda function. Replace pass with a lambda function that has expense as its parameter.
expense is expected to be a dictionary, and your lambda function should return the value of the 'amount' key in the expense dictionary.
--hints--
You should create a lambda function that uses the parameter expense and returns expense['amount'] in your total_expenses function.
({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_stmt("lambda expense: expense['amount']")`)) })
You should not have pass in your total_expenses function.
({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("total_expenses").has_pass()`)) })
--seed--
--seed-contents--
def add_expense(expenses, amount, category):
expenses.append({'amount': amount, 'category': category})
def print_expenses(expenses):
for expense in expenses:
print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')
--fcc-editable-region--
def total_expenses(expenses):
pass
--fcc-editable-region--
expenses = []