Back to Freecodecamp

Step 22

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

latest978 B
Original Source

--description--

You should see something like <map object at 0xd273a8> printed on the console, which is the string representation of the map object returned by map().

To obtain a readable output you need to turn the map object into a list. Do it by passing the map() call as the argument to the list() function.

--hints--

You should pass the map() call as the argument to the list() function.

js
({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) })

--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(map(test, [2, 3, 5, 8]))
--fcc-editable-region--

expenses = []