Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how do i fix this

+2 votes
asked Mar 6 by Vincent Detera (140 points)
print ("Hello Good day")
print ("-----------")
print ("How may i help you")

print ("[1] Items")
print ("[2] Back")
print ("[3] Check my Items")

choice = int(input("Enter the number of choice"))
if choice == 1:
    input("Press Enter to clear the screen...")
    print ("-----------------------")
    print ("Choose some items here")
    print ("-----------------------")
    print ("Heres our Items")
    print ("[1] NikeHoodie")
    print ("[2] NikeSpellout")
    print ("[3] NikeAlumni")
    print ("[4] NikeBigswoosh")
    print ("[5] NikeSideswoosh")
    print ("[6] NikeSb")
    print ("-----------------------")
    print ("-----------------------")
    add_choice = input("Enter your choice: ")
    if add_choice in == '0':
        continue
    elif add_choice in ['1', '2', '3', '4', '5', '6']:
        quantity = int(add_choice) * 6
        inventory.add_stocks(quantity)
        print(f"Added {quantity} to all products in inventory.")
    else:
        print("Invalid choice. Please enter again: ")
        
    elif choice == '2':
        product = input("Enter the product name: ")
        success = inventory.make_sale(product)
        if success
        print("Sale seccessful.")
        
    elif choice == '3':
        inventory.view_inventory()
        
    elif choice == '4':
        point_of_sale(inventory)
        
    elif choice == '5':
        break
    
    else:
        print("Invalid choice. Please enter again.")
        
        
        
if __name__ == "__main__":
    main()
    
    input("Press Enter to clear the screen...")

class ShoppingCart:
    def __init__(self):
        self.items = []

    def add_item(self, item_name, qty):
        item = (item_name, qty)
        self.items.append(item)

    def remove_item(self, item_name):
        for item in self.items:
            if item[0] == item_name:
                self.items.remove(item)
                break

    def calculate_total(self):
        total = 0
        for item in self.items:
            total += item[1]
        return total

cart = ShoppingCart()

cart.add_item("NikeAlumni", 4)
cart.add_item("NikeSpellout", 2)
cart.add_item("NikeHoodie", 1)

print("NikeAlumni, NikeSpellout, NikeHoodie:")
for item in cart.items:
    print(item[0], "-", item[1])

total_qty = cart.calculate_total()
print("Total Quantity:", total_qty)

print("\nUpdated Items in Cart:")
for item in cart.items:
    print(item[0], "-", item[1])

total_qty = cart.calculate_total()
print("Total Quantity:", total_qty)

1 Answer

+2 votes
answered Mar 7 by Peter Minarik (86,240 points)

You need to follow the compilers messages and fix things one by one.

  1. Instead of if add_choice in == '0': you should write if add_choice == '0':
  2. else should be at the end, after other elifs
  3. On line 26 you issue a continue command, but there is no loop to be continued. Put a loop around your menu.
  4. inventory is not defined. It is not clear if you'd want to use the ShoppingCart or a simple list here, but neither has add_stocks()make_sale() or view_inventory() functions. I belive you have some unfinished code here. You should also put any declaration, such as your ShoppingCart at the beginning of the file, before you start your code, so the compiler is aware of these type declarations.
Good luck!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...