Learn Lambda Functions by Building an Expense Tracker - Step 29

Tell us what’s happening:

can u pls help me with my code, idk what i am doing wrong everything looks alright to me

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"]}')
    
def total_expenses(expenses):
    return sum(map(lambda expense: expense['amount'], expenses))
    

# User Editable Region

def filter_expenses_by_category(expenses, category):
    lambda expense: expense['category'] == category, expenses

# User Editable Region

expenses = []

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36

Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 29

1 Like

you are not only writing the lambda, you are writing more than that

am i suppose to return it

no, you are asked to only write the lambda function

you have written that plus something else that you need to remove

I checked your code. The test wants only the lambda function. But right now, it looks like you’re creating a pair (a tuple) of the lambda and expenses. Just remove the extra part so only the lambda is in the function. Hope that helps. let us know if it works. Good luck!

Thank you both @ILM and @smit_007 , both really helped me complete this stage

1 Like