Learn Lambda Functions by Building an Expense Tracker - Step 18

I Have tried this to fix it for about a hours but i cant fix it please can any body help me.

pass your map() call to the sum() function.

Your code so far

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

# User Editable Region

def total_expenses(expenses):
    sum(map(lambda expense: expense['amount'], expenses))
expenses = []

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 18

You need to return the result as the request asks. Place the keyword return in front of the sum.

1 Like

I have tried as you said @anon28508191 but still not working. :pray: :pray:

Show me the change you made.

return, sum(map(lambda expense: expense['amount'], expenses))

You added something extra after return. Can you see it?

Ya of course i added , ohh Yes thank you i have removed , and it passes thanks for your great help.

1 Like

The confusion is strong in this one :laughing: i was able to pass on to the next step!
Thank you!

1 Like