Back to Freecodecamp

Step 15

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

latest1.1 KB
Original Source

--description--

Inside the print_expenses function, create a for loop that iterates over each item in the expenses list. Use expense as the loop variable and move pass inside the loop body.

--hints--

You should create a for loop that iterates over expenses in your print_expenses function. Remember to use pass within the loop body.

js
({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_iter().is_equivalent("expenses")`)) })

You should use expense as the loop variable.

js
({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_vars().is_equivalent("expense")`)) })

You should have pass only inside your loop body.

js
({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").has_pass()`)) })

--seed--

--seed-contents--

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

expenses = []