K
Karlo Lozovina
Here is it:
---
class Human:
def __init__(self, eye_one, eye_two):
self.eye_one = eye_one
self.eye_two = eye_two
class Population:
def __init__(self):
self.house = []
for i in range(0, POPULATION_COUNT):
self.house.append(Human(self.GenerateRandomColour(),
self.GenerateRandomColour()))
def GenerateRandomColour():
rn.seed()
colour = rn.choice(['C', 'P', 'Z'])
return colour
---
Uppon running it gives this error:
---
Initializing first generation population:
Traceback (most recent call last):
File "population.py", line 38, in ?
earth = Population()
File "population.py", line 26, in __init__
self.house.append(Human(self.GenerateRandomColour(),
self.GenerateRandomColour()))
TypeError: GenerateRandomColour() takes no arguments (1 given)
---
If I remove GenerateRandomColour from class definition, and put it as a
separate function, everything works fine. I've been staring at this code
for half an hour and can't find what's wrong
.
Any help greatly appriciated
.
---
class Human:
def __init__(self, eye_one, eye_two):
self.eye_one = eye_one
self.eye_two = eye_two
class Population:
def __init__(self):
self.house = []
for i in range(0, POPULATION_COUNT):
self.house.append(Human(self.GenerateRandomColour(),
self.GenerateRandomColour()))
def GenerateRandomColour():
rn.seed()
colour = rn.choice(['C', 'P', 'Z'])
return colour
---
Uppon running it gives this error:
---
Initializing first generation population:
Traceback (most recent call last):
File "population.py", line 38, in ?
earth = Population()
File "population.py", line 26, in __init__
self.house.append(Human(self.GenerateRandomColour(),
self.GenerateRandomColour()))
TypeError: GenerateRandomColour() takes no arguments (1 given)
---
If I remove GenerateRandomColour from class definition, and put it as a
separate function, everything works fine. I've been staring at this code
for half an hour and can't find what's wrong
Any help greatly appriciated