Fixed chromosome so now it adds to the database and added __str__ to chromo

This commit is contained in:
Daniel Wilczak
2020-11-16 17:14:09 -05:00
parent 8b6b880ada
commit 2efebc4bcd
2 changed files with 14 additions and 4 deletions

View File

@ -59,4 +59,16 @@ class Chromosome:
output_str = ''
for gene in self.gene_list:
output_str += gene.__repr__()
return output_str
def __str__(self):
"""Create a string of the chromosome. Ex chromsome = 1,2,3"""
output_str = ''
for gene in self.gene_list:
if gene == self.gene_list[0]:
output_str += str(gene.get_value())
else:
output_str += ',' + str(gene.get_value())
return output_str