I am building a program which involves lots of objects stored in a list. In my simplified code below, I have changed it so that the objects are instances of class 'Person', with a people[] list used to store the values for two Person instances. The code is below.
class Person:
age = 0
people = []
for i in range (0, 2):
people.append(Person)
people[0].age = 10
people[1].age = 50
print(people[0].age, people[1].age)
I expect the first Person object ( people[0] ) to get 10 for its age parameter, and people[1] to get the value 50 for the same variable. However, both people[0] and people[1] get 50 when I run the code.
What have I done wrong here, and what can I do so that people[0] gets 10 and people[1] gets 50?