Untitled
unknown
plain_text
2 years ago
1.1 kB
9
Indexable
class Item:
def __init__(self,name,price,quantity):
self.name=name
self.price=price
self.quantity=quantity
self.intro()
item1 = Item("i1",88.2,8)
item2 = Item("i2",40.8,2)
item3 = Item("i3",55.08,1)
item4 = Item("i4",22.9,3)
item5 = Item("i5",1000.8,6)
inventory=[item1,item2,item3,item4,item5]
for i in inventory:
print(f"Name: {i.name},Price : {i.price},Quantity: {i.quantity}")
def intro(self):
choice=int(input(''' Enter your choice:
1.Add New Item
2.Update the quantity of an existing item
3.Remove an item '''))
if choice == 1 :
self.add()
elif choice == 2:
pass
elif choice ==3:
pass
def add(self):
self.name = input("Enter the name ")
self.price=float(input("Enter the price "))
self.quantity=int(input("Enter the quantity"))
print("{} {} {} ".format(self.name,self.price,self.quantity))
Editor is loading...