You are on page 1of 3

inventory={}

inventory.update({'Steel':{"stock":200, "price":1000},

'Concrete':{"stock":900, "price":550},

'Cement':{"stock":700, "price":250},

'Bricks':{"stock":950, "price":700},

'Wood':{"stock":800, "price":180}})

print("\n1. Add item")

print ("2. Remove Item")

print ("3. View Inventory")

print ("4. Update Inventory")

print ("5. Exit")

choice = int(input ("Enter your choice(1-5): "))

if choice in {1,2,3,4,5}:

if choice == 1:

name = input( "Enter item name: ")

stock = int(input("How many stock would you want to add?: "))

price = float(input("How much price per item: "))

inventory[name] = {"stock": stock, "price": price}

print(f" {name} has been added to the inventory.")

print (inventory)

inventory = inventory

if choice == 2:

option = input("Remove by name or stock?")

if option == "name":

name = input ("Enter item name:")


if name in inventory:

del inventory[name]

print(f" {name} has been removed from the inventory.")

print (inventory)

else:

print(f" {name} is not in the inventory.")

elif option =="stock":

stock = int(input("Enter number of items in stock:"))

for name, values in inventory.items():

if values["stock"] == stock:

del inventory [name]

print (f" {name} has been removed from the inventory")

print (inventory)

break

else:

print (f"No item with {stock} items in stock found in the inventory.")

else:

print("Invalid option.")

inventory = inventory

if choice == 3:

if not inventory:

print ("Inventory is Empty.")

else:

print("Item Stock Price")

for name, values in inventory.items():

print(f"{name:10} {values['stock']:11} {values['price']:11}")

inventory = inventory
if choice == 4:

name = input ("Enter Item Name:")

if name in inventory:

stock = int(input("Enter New Number of Items in Stock:"))

price = float (input("Enter New price per item:"))

inventory[name] = {"stock":stock, "price": price}

print (f" {name}'s inventory has been updated.")

print (inventory)

else:

print (f" {name} is not in the inventory.")

elif choice == 5:

print ("Exiting program.")

else:

print("Invalid choice. Please enter a number between 1 and 5.")

You might also like