Simulation in python

```import random

startpopulation=50

infantmortality=25

agriculture=5

disasterchance=10

food=0

fertilityX=18

fertilityY=35

peopledictionary=

class person:

def __init__(self,age):

self.gender=random.randint(0,1) self.\_age=age self.pregnant=0

def harvest(food,agriculture):

ablepeople=0

for person in peopledictionary:

if person.\_age >8: ablepeople +=1

food += ablepeople * agriculture

if food < len(peopledictionary):

del peopledictionary\[0:int(len(peopledictionary)-food)\] food = 0

else:

food -= len(peopledictionary)

def reproduce (fertilityX, fertilityY,infantmortality):

for person in peopledictionary:

if person.gender==1: if person.\_age > fertilityX: if person.\_age \< fertilityY: if random.randint(0,5)==1: if random.randint(0,100) > infantmortality: peopledictionary.append(person(0))

def beginSim():

for x in range(startpopulation):

peopledictionary.append(person(random.randint(18,50)))

def runYear(food, agriculture, fertilityX, fertilityY, infantmortality, disasterchance):

harvest(food, agriculture)

for person in peopledictionary:

if person.\_age > 80: peopledictionary.remove(i) else: person.\_age +=1

reproduce(fertilityX, fertilityY, infantmortality)

if random.randint(0,100)<disasterchance:

del peopledictionary\[0:int(random.uniform(0.05,0.2)\*len(peopledictionary))\] print(len(peopledictionary)) infantmortality \*= 0.985 return infantmortality

beginSim()

while len(peopledictionary)<100000 and len(peopledictionary) > 1:

infantmortality = runYear(food, agriculture, fertilityX, fertilityY, infantmortality, disasterchance)```

`I am getting an error which says “person” object is not callable. kindly help me figure out the reason and the solution of the problem`Preformatted text

Hi, Requesting you to indent the code properly or attatch a screenshot so that we can take a look easily.

https://drive.google.com/file/d/1bU_cweAAqD40E-F5RI60JAIz8fcplvtO/view?usp=sharing

In the above link you will get the ipynb file of the code

At all places where you are accessing peopledictionary, replace the iterator name from ‘person’ to something else for e.g.

for human in peopledictionary:
           if human._age >8:

using the class name (person) as variable name is creating problem, I think.