Files
freeCodeCamp's Camper Bot 64697d4ca7 chore(i18n,learn): processed translations (#54988)
Co-authored-by: Naomi <commits@nhcarrigan.com>
2024-05-28 16:57:56 +09:00

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 = []