Learn Lambda Functions by Building an Expense Tracker - Step 4

Tell us what’s happening:

I have tried so hard. Why my code is not running ?

Your code so far


# User Editable Region

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


# User Editable Region

expenses = []

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Lambda Functions by Building an Expense Tracker - Step 4

you are welcome @ patelujas9999 to the https://forum.freecodecamp.org/.
if your code is not running, please rest it the lesson after that follow it what the instraction says.
keep it up!

Hi Patel,

Let’s reset the code and try again.

This is the original code:

def add_expense(expenses, amount, category):
    expenses.append()

This is what the instruction asked:

Create a dictionary with a key 'amount' and value of the amount parameter and pass your new dictionary to the .append() call.

We can break it into 2 smaller steps:

Step 1:

Create a dictionary with a key 'amount' and value of the amount parameter

In the given example code, we have this dictionary:

{'amount': 50.0}

This is a dictionary with a key 'amount' and the value: 50.0.
The dictionary we need to create also have a key 'amount', the value is not 50.0 but is: amount.

Step 2:

pass your new dictionary to the .append() call.

This basically means put the dictionary we created on step 1 between the parentheses() in the function call: expenses.append()

Hope this will help.