class phone:
def __init__(self,brand,model,price,amount):
self.brand=brand
self.model=model
self.price=price
self.amount=amount
Nokia = phone("Nokia", 321, 150, 20)
Samsung = phone("Samsung", "A8", 190, 30)
iPhone = phone("iPhone", 5, 230, 40)
phones = []
def objectlist(Nokia,Samsung,iPhone):
phones.append(Nokia)
phones.append(Samsung)
phones.append(iPhone)
objectlist(Nokia,Samsung,iPhone)
This is the problem that I'm working on for a school assignment, I was wondering if there is a way to add all objects associated with a class to a list, without having to point out each individual object and add it one by one?