Jun-28-2024, 02:59 PM
What it needs to do....
What I have...
This is what I have def in main...
Quote:2. InputExpenseNames
First create an empty list for expense items. Next, enter a loop that iterates for as long as the user
responds that there are more item names to enter. In the loop, display a message asking the user to
input the name of an expense item, then input the name and append it to the list. Then input a
response to the question whether there are more item names.
After the loop ends, return the expense items list.
3. InputExpenseAmounts
Create an empty list for expense amounts. Enter a loop that uses the size (you may use the len
function) of the expense items list to determine number of iterations. For each iteration, display a
message that says:
How much was spent on xxxxxxxxxx expense item?
where xxxxxxxxxx is replaced by the name from the expense_items_list corresponding to the current
iteration. The amount should then be input and appended to the expense amounts list. Input
validation should be done including using try … except … to ensure a number was entered.
After the loop ends, return the expense amounts list.
What I have...
def InputExpenseNames(): expenseItems = [] name = input("Enter expense name (q for quit):") while name != "q" : expenseItems.append(name) name = input("Enter expense name (q for quit):") return expenseItems #expense amounts expenseAmounts def InputExpenseAmounts(expenseItems): expenseAmounts = [] print('How much was spent on ') for i in expenseItems: amount = int(input(i + 'expense items?')) expenceAmount.append(amount) return expenseAmountsWhat I am getting is it goes back to the main_menu and not allowing me to input. Recommendations on how to fix this so I can input into the expenseItems list.
This is what I have def in main...
while choice != quitOp: main_menu() choice = int(input('Enter expense report option: ')) if choice == nameOp: InputExpenseNames() elif choice == amountOp: InputExpenseAmounts(expenseItems) elif choice == reportOp: displayExpenseReport(expenseItems, expenseAmounts) else: print('Thank you, goodbye')