hi all. i’m trying to understand classes but struggling. trying to make a simple class where it adds a name to a list then i can print it but nothing is printing can you guys help?
class Person:
List = []
def __init__(self, name):
self.name = name
self.List.append(name)
def printnames(self):
for i in range(len(self.List)):
print(self.List)
Ollie = Person("ollie")
John = Person("John")
Person.printnames
class Person:
List = []
def __init__(self, name):
self.name = name
self.List.append(name)
def printnames(self):
for i in range(len(self.List)):
print(self.List)
Ollie = Person("ollie")
John = Person("John")
Person.printnames