Learn Lambda Functions by Building an Expense Tracker - Step 15

Tell us what’s happening:

Im fairly sure I am using expense as the loop variable. I cannot see what I am missing here.

Any help is appreciated

Your code so far

def add_expense(expenses, amount, category):
    expenses.append({'amount': amount, 'category': category})
    

# User Editable Region

def print_expenses(expenses):
    for expense in expenses():
        pass

# 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/133.0.0.0 Safari/537.36

Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 15

Have you tried to call the print_expenses? It might give you some hints what’s happening. Try adding at the bottom:

expenses = [{'amount': 10, 'category': 'category1'}, {'amount': 5, 'category': 'category2'}]
print_expenses(expenses)

That causes a TypeError saying ‘list’ object is not callable.

Im really lost as to what I am missing here

and do you see where that error comes from?

got it now. It was alot easier than I realised. I just had to remove one very simple part of the code. Though, I thought that part was necessary

1 Like

the () are used only to call functions, if your thing is not a function you should not try to call it