curriculum/challenges/english/blocks/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md
The input() function takes a user input and it returns the user input in the form of a string.
Inside your while loop, call the input() function passing the string 'Enter your choice: ' as the argument, and assign the result to a variable named choice.
You should declare a variable named choice within your while loop.
({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].has_variable("choice")
`)) })
You should assign the result of the input() function, with the string 'Enter your choice: ' as its argument, to your choice variable.
({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_variable("choice").is_equivalent("choice = input('Enter your choice: ')")
`)) })
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 = []
while True:
print('\nExpense Tracker')
print('1. Add an expense')
print('2. List all expenses')
print('3. Show total expenses')
print('4. Filter expenses by category')
print('5. Exit')
--fcc-editable-region--