class obj:
def __init__(self, a):
self.a = a
class obj2 :
def __init__(self, a):
self.a = a
pList = [obj(1),obj(2),obj(3),obj(4),obj(5)]
list = []
for i in pList:
obj2(i.a)
list.append(obj2)
for i in list :
print(i.a)
Hi friend. Im python newBie. I have this code but it doesn't work.
please teach me.. thank you
Traceback (most recent call last):
File "D:/..py", line 18, in <module>
print(i.a)
AttributeError: type object 'obj2' has no attribute 'a'
Process finished with exit code 1
listfor your variables. And don't call your files..py.