改变列表中的元素

时间:2017-02-28 04:46:29

标签: python list loops elements

我制作了一个列表,对该列表中的数字进行了平均,然后尝试减去差异并将其平方,但我得到此错误“TypeError:'tuple'对象不支持项目分配”任何人都知道为什么?这是我的代码:

a = [s1,s2,s3,s4,s5,s6] = eval(input("what's the scores from X1, separate by commas? "))

b = [d1,d2,d3,d4,d5,d6,d7,d8,d9] = eval(input("what's the scores from X2, separate by commas? "))

average1 = (sum (a))/6 
average2 = (sum (b))/9

for j in range (len(a)):
    a[j] = (a[j]-average1)**2

for d in range (len(b)):
    b[d] = (b[d]-average2)**2

0 个答案:

没有答案