Jun-27-2022, 03:50 AM
(Jun-26-2022, 11:29 PM)rob101 Wrote: If you want to take this forward, then it may be best if you posted the assignment notes, so that we don't start down the wrong road.we had to have 5 options and then where we could view the cart and remove an item. it also has to have where you can have more than one item to compute the notes he posted only had for list's which I got stuck many of the other students as well
IMHO you don't need more than 3 user options, which will make for a more user friendly experience. As an example, why make the user have to 'choose' to view the shopping cart (unless that's a part of the assignment notes)? Surely this should be on display by default.
The total cost of the shopping can also be a part of the shopping cart view function, so no need for any 'Compute total'.
This is the approach I would take:
cart = [] #holds the cart items item_price = [] #holds the price of each item while True: if cart: #call the view cart function so that the shopping cart is always on display pass #remove this line when the function has been defined else: print("\nYour shopping cart is empty.\n") print("Shopping Cart Options\n") print ("1. Add items") print ("2. Remove Items") print ("3. Quit") option = input("> ") if option == '1': #call the add items function pass #remove this line when the function has been defined if option == '2': if cart: #call the remove items function pass #remove this line when the function has been defined else: print("\nThere are no items in your shopping cart.\n") if option == '3': if cart: #warn the user that there are items in the shopping cart and get positive feedback before quitting pass #remove this line when the above in functional else: print("\nYour shopping cart is empty.\n") check = "yes" if check == "yes": print("\nApplication exit") break