curriculum/challenges/english/blocks/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md
In Python, an important thing to know is that the same type of quote used to define a string cannot be used inside it. For example, the string 'I'm a string!' is not valid. To use the single quote inside that string you should either:
'I\'m a string!'"I'm a string!" (preferred).You can access values in a dictionary through its keys. You need to use bracket notation and include the key between the square brackets:
my_dict = {'amount': 50.0, 'category': 'Food'}
my_dict['amount'] # 50.0
You are currently interpolating the expense dictionary in your f-string. Modify the f-string expression to access the value of the 'amount' key and the 'category' key in the expense dictionary.
You should pass f'Amount: {expense["amount"]}, Category: {expense["category"]}' to your print() call. Remember to use double quotes within your single-quoted f-string and vice versa.
({ test: () => assert.match(code, /^\s+print\s*\(\s*f("|')Amount: \{\s*expense\s*\[\s*(?=[^\1])("|')amount\2\s*\]\s*\}, Category: \{\s*expense\s*\[\s*(?=[^\1])("|')category\3\s*\]\s*\}\1\s*\)/m) })
def add_expense(expenses, amount, category):
expenses.append({'amount': amount, 'category': category})
--fcc-editable-region--
def print_expenses(expenses):
for expense in expenses:
print(f'Amount: {expense}, Category: {expense}')
--fcc-editable-region--
expenses = []