迭代时保持 'float' 不可订阅

Keep having 'float' not subscriptable when iterating

我正在尝试做一些数学运算,为此我必须遍历一组浮点数,但令我惊讶的是我做不到。继续 TypeError: 'float' object is not subscriptable

    m = len(x)
    sx = sum(x)
    sy = sum(y)
    sxx = sum([i**2 for i in x])

    for i in range(m):
        print(i)
        sxy += sx[i]*sy[i] 
 #it should be: sxy += x[i]*y[i]

不熟悉python,顺便说一句

sx 是一个浮点数,例如3.14 因此你不能使用 sx[i],与 sy

相同