So, I was trying to develop a game in PyGame and came across a problem. I tried it it on a much simpler code and it still returns an error, so I think it's not about my big code. Here's what goes wrong (the short version)
from random import randint as rand
def A():
def __init__(self):
self.n = rand(1,10)
b = []
for i in range(10):
b.append(A())
for i in range(10):
print(str(b[i].n))So, basically, I'm filling "b" with a list of 10 "a" objects. Each object gets assigned a random value on its __init__. Then I iterate through all the objects printing their "n" value. Well, instead of printing some random numbers, it gives me an error: Error:Traceback (most recent call last):
File "C:/Users/sergio/Desktop/python/test/d.py", line 11, in <module>
print(str(b[i].n))
AttributeError: 'NoneType' object has no attribute 'n'Any help would be appreciated.
