gpt4 book ai didi

python - 我收到错误TypeError : 'int' object is not callable

转载 作者:行者123 更新时间:2023-12-02 11:07:22 26 4
gpt4 key购买 nike

richness = int(input("How many species are in your ecosystem? "))
population = 0
for x in range (1, (richness+1)):
population = population + int(input("What's the population of species " + str(x) + "? "))
print("Your species richness is " + str(richness))
print("Your simpsons biodiversity index is " + str(1-((population(population-1))/(richness(richness-1)))))
我是为一个Bio项目写的,但我不知道是什么问题。它似乎来自最后一行。

最佳答案

您调用population(population - 1)(在最后一行),当它是一个变量时,它将population视为一个函数。
如果要“将它们多个”,则必须使用population * (population - 1)明确声明。 richness存在相同的问题

关于python - 我收到错误TypeError : 'int' object is not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64487234/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com