Learn Lambda Functions by Building an Expense Tracker - Step 23

Tell us what’s happening:

I’m not sure what I’m doing wrong with the return 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"]}')
    
def total_expenses(expenses):
    return sum(map(lambda expense: expense['amount'], expenses))
    

# User Editable Region

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

# 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 23

You are trying to return this variable which does not exist.

You can do this all on one line just by adding return

1 + 1
return 1 + 1

You have a filter expression but it’s not going anywhere, not stored in a variable or anything. Adding return tells it where to go.