Back to Freecodecamp

Step 24

curriculum/challenges/english/blocks/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md

latest809 B
Original Source

--description--

Next, you are going to implement the same logic within the total_expenses function.

For now, delete both the test function and the print() call.

--hints--

You should delete your test variable and the related print() call.

js
({ test: () => assert.isFalse(runPython(`_Node(_code).has_variable("test")`)) })

--seed--

--seed-contents--

py
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"]}')

def total_expenses(expenses):
    pass
    
--fcc-editable-region--
test = lambda x: x * 2
print(sum(map(test, [2, 3, 5, 8])))
--fcc-editable-region--

expenses = []