I'm trying to design a function in Python which instantiates a number of objects based on a user input. I've derived one which works, and it looks as follows
class Node(): ...
def initialise():
binary_tree=[]
opt=int(input("Enter the number of nodes you want\n"))
for i in range(opt):
a=Node()
binary_tree.append(a)
although I'm not sure that this is the ideal way to do this.
Is there a better way of programming a function such as the one I've described, or is the above method sufficient for efficiency and clarity purposes?
Any responses are appreciated, thank you in advance.