I am trying to create a list of N instances of class Name and then call back a parameter of that instance. My code is below.
I get an error: Exception has occurred: AttributeError 'str' object has no attribute 'get_name'
and am not sure how to fix it. Any ideas? Thank you
class Name:
global listName
listName = []
def __init__(self,name):
self.name = name
listName.append (self.name)
@property
def get_name (self):
print (self.name)
for i in range (10):
Name(f"Name{i}")
for i in range (10):
listName[i].get_name