so I am trying to create many instances of the same class in python and store them in a list and use them as necessary. This is due to the fact that in the eventual script I will use this in I need a variable number of instances of this class.
So my code is:
class Node():
def __init__(self,index):
self.index = index
def printer(self):
print(self.index)
classlist = []
for i in range(100):
classlist.append(Node(i))
for i in classlist:
print(i.printer())
So I get the correct printed index output but I keep also getting None
so the output is:
0
None
1
None
2
None
3
None
4
None
5
None
What am I doing that causes the None to be printed? how can I stop this?