Here @bitassassin i’ll try to explain it better.
I’m making a game where you start with four villagers. Each villager has a positive and negative personality trait, age and a job. The game goes by in seasons, and you will be prompted to do things in special events.
Villagers will eventually reproduce, meaning that the new villagers will need new variables for each one. You should be able to have an infinite amount of villagers, so predefining the variable for each villager that is to be born is useless. Example:
villager1 = [personality, personality, age, job]
villager2 = [personality, personality, age, job]
villager3 = [personality, personality, age, job]
villager4 = [personality, personality, age, job]
etc...
So i researched if there could be a solution and a heard that classes and objects could do this. I never delved into OOP because it always results in headaches and me not getting anywhere. Then, once i had finally made learnt how to make classes and from them objects, i encountered the same problem: You need a variable for each villager. Example:
class Person(object):
"""A friendly villager"""
def __init__(self, name):
print("A villager has been born by the name of " + name)
self.name = name
#Other methods go here such as attributes & job calculation
print("Please input four names, one at a time")
vil0 = Person(input())
vil1 = Person(input())
vil2 = Person(input())
vil3 = Person(input())
The problem is writing a variable/list for each existing variable and for all villagers to come.
Sorry if this is still vague, I don’t know how else to explain it.