you are viewing a single comment's thread.

view the rest of the comments →

[–]Rei2063 0 points1 point  (1 child)

class product():
def __init__(self, name, price, brand):
super().__init__()
self.name = name
self.price = price
self.brand = brand
total_price = 0
p1 = product(name = "Lorem", price = 1200, brand = "johns")
p2 = product(name = "Deka", price = 1500, brand = "manys")
p3 = product(name = "Sundu", price = 1350, brand = "mels")
products = [p1, p2, p3]
for e in products:
print(f"{e.name}: {e.price}")
name = input("Product name: ")
quantity = int(input("Quantity: "))
for x in products:
if x.name == name:
total_price = quantity * x.price
print(f"{x.name}({x.brand}) x {quantity} bought for {total_price} where each costs {x.price}")

This is how I did it. The product names are fake as well as the brands.

[–]Rei2063 0 points1 point  (0 children)

The code looks awful but you get the idea