我是 python 初学者。我试图运行这段代码:
def main():
print ( " This program computes the average of two exam scores . ")
score1,score2 = input ("Enter two scores separated by a comma:")
average = (score1 + score2)/2.0
print ("The average of the score is : " , average )
当我召唤 main()
我得到这个 ValueError
:
ValueError: too many values to unpack (expected 2)
这段代码有什么问题?
原文由 DAVID 发布,翻译遵循 CC BY-SA 4.0 许可协议
score1 + score2
将进行字符串添加,否则您将得到一个错误。