我是python新手,可能不太熟悉详细的语法规则。在
我能知道如何解决这个错误吗?它指向6、7、8号线,我不确定出了什么问题。谢谢!在
def calculate_average_expenditure(a):
totalincome = 0
totalsavings = 0
count = 0
for item in a:
if (item['AGE2011'] >= 20 and item['AGE2011'] <= 30):
totalincome += item['INC2011']
totalsavings += item['SAV2011']
count += 1
totalexpenditure = totalincome-totalsavings
return totalexpenditure/count
编辑: 谢谢,我通过调整方法的调用方式使它工作起来。在
^{pr2}$
我猜参数
a
绑定到一个字符串列表。你能告诉我你怎么称呼calculate_average_expenditure(...)
和...
包含什么吗?在相关问题 更多 >
编程相关推荐