Attempting to append a dictionary to my list. Everything looks right, but the code doesn’t pass. I don’t understand what I’m doing wrong.
Your code so far
# User Editable Region
def add_expense(expenses, amount, category):
my_dict = {'amount': amount, 'category': category}
expenses.append(my_dict)
# User Editable Region
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 Edg/126.0.0.0
Challenge Information:
Learn Lambda Functions by Building an Expense Tracker - Step 4
I figured as much. TBH, this isn’t my first attempt. I’ve tried it with 1 key/value pair and got the same result. I understand the code is read top down, so I believe that I need to create the expenses list first, create the dictionary, and then append the dictionary to the list. I’m missing something and I can’t figure it out…
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.
The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.