I am trying to utilize a while loop with an if-else ladder nested inside in order to take user input for menu items and add menu item prices together. No matter what I have tried I cannot seem to get the total_cost variable to add the listed prices depending on user input. All I can get it to return as a value is 0.0 (which would be the value I used to initialize the total_cost variable at the beginning).
Here is my code:
Thank you!
Here is my code:
#Displaying the menu def display_menu_of_food_items(): print(" 1) eggs $3.25 \n 2) bacon $4.00 \n 3) pancakes $2.50 \n 4) orange juice $1.25 \n 5) oatmeal $3.99 \n 6) milk $1.25 \n 7) donut $2.00") return (display_menu_of_food_items) display_menu_of_food_items() def get_menu_item(): menu_item = print (input("Please enter menu line number of diner's desired item ")) return (menu_item) get_menu_item() #Collecting what a customer would like to order for their meal def get_diner_order(): total_cost = 0.00 display_menu_of_food_items() while input("Do you want to order an item? Answer y or n") == 'y': get_menu_item() order = input() if (order == 1): total_cost = total_cost + 3.25 elif (order == 2): total_cost = total_cost + 4.00 elif (order == 3): total_cost = total_cost + 2.50 elif (order == 4): total_cost = total_cost + 1.25 elif (order == 5): total_cost = total_cost + 3.99 elif (order == 6): total_cost = total_cost + 1.25 elif (order == 7): total_cost = total_cost + 2.00 else: print (float(total_cost)) return total_cost get_diner_order()Any help would be greatly appreciated, I am a beginning coder and have been stuck in this same spot for several days now.
Thank you!