Learn Lambda Functions by Building an Expense Tracker - Step 17

Tell us what’s happening:

I will need help to solve step 17. I have try interpreting the instruction and have the following :
return (lambda expense: expense[‘amount’], expenses)

Is there anything that I missed? Please help

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):
    return (lambda expense: expense['amount'], expenses)

# User Editable Region


expenses = []

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15

Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 17

1 Like

Replace pass with a lambda function that has expense as its parameter.

You need only the lambda function to pass this step. Remove the unnecessary parts and you’ll be able to pass.

2 Likes

I applied your advice and pass the test. Thanks.

1 Like

I have the same problem and have no clue how to solve it. Read the documentation on lambda function, looked through a lot of examples. My code won’t pass.
Here it is:

def total_expenses(expenses):
    return lambda expense : expense['amount']

Found solution online. It was not easy )
For future students who will get stuck on this step , I can recommend this useful article:

2 Likes