class Cars(object):
def __init__(self,brand=None,color=None,cost=None):
self.brand = brand
self.color = color
self.cost = cost
imagine i have 300 cars (from car1 to car300)
dict = {"car1":["Toyota","Red",10000],
"car2":["Tesla","White",20000],
"car3":["Honda","Red",15000]
}
What I have tried:
dict1 = globals()
for k,v in dict.items():
dict1[f"{k}"] = Cars(v[0],v[1],v[2])
print(k,v)
Is this the best possible way to do it?
Is this an aggressive way to do it?
I wold like to learn a efficient, safe way to do it