class product():
def __init__(self, price, product_id, quantity):
self.price = price
self.product_id = product_id
self.quantity = quantity
def calculate_value(*stuff):
print(sum(stuff.price*stuff.quantity))
a = product(2,"a", 2)
b = product(3, "b", 3)
calculate_value(a,b)
Error:
Traceback (most recent call last):
File "/Users/apple/Desktop/Python/product_inventory_project.py",
line 17, in <module>
calculate_value(a,b)
File "/Users/apple/Desktop/Python/product_inventory_project.py",
line 11, in calculate_value
print(sum(stuff.price*stuff.quantity))
AttributeError: 'tuple' object has no attribute 'price'
What am I doing wrong here? I feel the *args in calculate_value is causing issues, but I am unable to see the fault. Much thanks!