Back to Freecodecamp

Step 13

curriculum/challenges/english/blocks/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md

latest1014 B
Original Source

--description--

Add another key-value pair to the dictionary you are appending to the expense list. Use the string 'category' as the key, and the category parameter as the value.

--hints--

You should add a second key-value pair to the dictionary you are passing as the argument to the .append() method.

js
({ test: () => assert(runPython(`
import ast
node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args()
len(node) == 1 and isinstance(node[0].tree, ast.Dict) and len(node[0].tree.keys) == 2
`)) })

You should pass {'amount': amount, 'category': category} as the argument to the .append() method.

js
({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount, 'category': category})")`)) })

--seed--

--seed-contents--

py
--fcc-editable-region--
def add_expense(expenses, amount, category):
    expenses.append({'amount': amount})
--fcc-editable-region--

expenses = []