【发布时间】:2021-11-03 17:19:25
【问题描述】:
我想知道什么更大?索引为 1 的数字的总和或列表前半部分的总和。我得到了这个错误。
TypeError: 'function' object is not subscriptable
def funky2(b):
c = checker[:len(b)/2]
a = sum(b) / len(b)
if a > sum(c):
return f'Statistic means is more than sum of 1 to half of list'
else:
return f'Statistic means is less than sum of 1 to half of list'
def checker(list):
b = []
for elem in list:
if list.index(elem) % 3 == 1:
b.append(elem)
return funky2(b)
print(checker([1,2,3,4,5,6,7,8,9]))
【问题讨论】: