curriculum/challenges/english/blocks/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md
A while loop is another kind of loop that runs a portion of code as long as a specified condition is True. The loop terminates when the condition becomes False:
while condition:
<code>
Below the expenses list, create a while loop. Use True for the condition, and print the string '\nExpense Tracker' inside the loop body to show the title of the program.
You should create a while loop using True as the condition within your main() function.
({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_conditions()[0].is_equivalent("True")`)) })
You should print '\nExpense Tracker' in your while loop.
({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print")[0].is_equivalent("print('\\\\nExpense Tracker')")`)) })
def add_expense(expenses, amount, category):
expenses.append({'amount': amount, 'category': category})
def print_expenses(expenses):
for expense in expenses:
print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')
def total_expenses(expenses):
return sum(map(lambda expense: expense['amount'], expenses))
def filter_expenses_by_category(expenses, category):
return filter(lambda expense: expense['category'] == category, expenses)
--fcc-editable-region--
def main():
expenses = []
--fcc-editable-region--