Python Forum
Shopping cart program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shopping cart program
#1
#This is a shopping cart program that I am doing for school. I've managed to store the item and price. But can't get to do it the total or remove. I'm new too this and have tried many different methods and it hasten worked. If someone can help please reply
print("Welcome to the Shopping Cart Program!")
cart = []
prices = []
total = []
total_price = []
while True:
    print()
    print ("Please type in one of these")
    print ("1. Add item ")
    print ("2. View cart ")
    print ("3. Remove Item ")
    print ("4 compute total")

    select = int(input(" Type in a number to go on "))
    item = ""
    if select == 1:
        while item != "ok":
            item = input(" What would you like to add?  ")
            price = float(input(" type in the price "))
            prices.append(price)
            
            ok = input ("type in ok when you're done.")
            if item != "ok":
                cart.append(item)
                print(f"'{item}' has been added to your cart.")
                print(f" The price is ${price}")
                break
    if select == 2:
        print("This is what is in your shopping cart")
        for item in cart:
            print(item,price)
            ok = input ("press ok when you're done")
            if item != "ok":
                break
            
    
                    
    if select == 3:
        takeout = input(" Type in what you would like to remove?  ")
        cart.remove(takeout)
        continue
        
    
    if select == 4:
        for price in total_price:
            sum+= price
            print(sum(total_price))
            input ("type in ok when you're done")
            if item != "ok":
                break
            
            
        
    if select == 5:
        print ("comeback soon.")
        break
Yoriz write Jun-26-2022, 06:20 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to ensure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Shopping cart program - by Tofuboi03 - Jun-26-2022, 06:12 AM
RE: Shopping cart program - by rob101 - Jun-26-2022, 07:36 AM
RE: Shopping cart program - by rob101 - Jun-26-2022, 11:29 PM
RE: Shopping cart program - by Tofuboi03 - Jun-27-2022, 03:50 AM
RE: Shopping cart program - by BashBedlam - Jun-26-2022, 11:58 PM
RE: Shopping cart program - by Tofuboi03 - Jun-27-2022, 03:43 AM
RE: Shopping cart program - by rob101 - Jun-27-2022, 07:53 AM
RE: Shopping cart program - by shoesinquiry - Sep-07-2023, 09:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  project shopping cart pkmnmewtwo 1 3,344 May-03-2020, 10:46 PM
Last Post: pkmnmewtwo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020