Untitled

 avatar
unknown
plain_text
a year ago
666 B
3
Indexable
class Item:
    def __init__(self,name,price,quantity):
        self.name = name
        self.price = price
        self.quantity = quantity

item1 = Item('item1',2.3,90)
item2 = Item('item2',3.2,20)
item3 = Item('item3',4.5,70)
item4 = Item('item4',7.9,30)
item5 = Item('item5',5.7,60)

inventory = [item1,item2,item3,item4,item5]

for i in inventory:
    print(f'Name :{i.name},Price :{i.price},quantity :{i.quantity}')

def add(inventory):
    name = input("Enter the name of item :")
    price = float(input("Enter the price :"))
    quantity =int(input("Enter the Quantity :"))
    abc = Item(name,price,quantity)
    inventory.append(abc)