Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World example #5

Open
pincher-chen opened this issue Apr 25, 2017 · 1 comment
Open

Hello World example #5

pincher-chen opened this issue Apr 25, 2017 · 1 comment

Comments

@pincher-chen
Copy link

$ python3 test_1.py
Traceback (most recent call last):
File "test_1.py", line 45, in
best, best_score, average_score = dna_stats(population)
File "test_1.py", line 37, in dna_stats
average_score = sum(member.score for member in population) / len(population)
TypeError: unsupported operand type(s) for +: 'int' and 'method'

@liuruoze
Copy link

liuruoze commented Jun 24, 2018

The reason is that there is a missing of '()' after score, try this code.

def dna_stats(population):
    '''Best DNA, best score, average score'''
    best_dna = max(population)
    best_score = best_dna.score
    average_score = sum(member.score() for member in population) / len(population)

    return best_dna, best_score, average_score

liuruoze added a commit to liuruoze/genetics that referenced this issue Jun 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants