Python 类型错误:';浮动';对象是不可编辑的

Python 类型错误:';浮动';对象是不可编辑的,python,Python,我正在编写一个程序,从一个列表(data1)中计算出10个数字的最小值和最大值。我收到以下行的“TypeError:“float”对象不可编辑”: temp_min10=min(data1[x-z][3]) temp_max10=max(data1[x-z][2]) 完整程序: x=int(0) for line in data1: if x>=9: min10=0 max10=0 for z in range(0,10):

我正在编写一个程序,从一个列表(data1)中计算出10个数字的最小值和最大值。我收到以下行的“TypeError:“float”对象不可编辑”:

temp_min10=min(data1[x-z][3])
temp_max10=max(data1[x-z][2])
完整程序:

x=int(0)
for line in data1:
    if x>=9:
        min10=0
        max10=0
        for z in range(0,10):
            temp_min10 = temp_max10 = 0
            temp_min10=min(data1[x-z][3])
            if temp_min10<min10:
                min10=temp_min10
            temp_max10=max(data1[x-z][2])
            if temp_max10>max10:
                max10=temp_max10
            d_chan.append([max10,min10])
    else:
        d_chan.append([0,0])
        x+=1
x=int(0)
对于data1中的行:
如果x>=9:
min10=0
max10=0
对于范围(0,10)内的z:
温度最小10=温度最大10=0
temp_min10=min(数据1[x-z][3])
如果温度最小10max10:
max10=温度×最大值10
d_chan.append([max10,min10])
其他:
d_chan.追加([0,0])
x+=1

谢谢你的帮助

最小和最大的可能参数是一个iterable或两个或多个标量。医生。你给了它一个参数,它不是一个可数;这是一个浮子

min_number = reduce(min,data1)
max_number = reduce(max,data1)
旁白:(1)显示的缩进明显不正确。您需要(a)避免源文件中的制表符(b)确保缩进在逻辑上是正确的。(2) 您的代码正在对data1:中的行迭代
,但从未再次提到
;看起来您需要仔细检查您正在使用
x
执行的操作;这不明显

再次阅读代码后更新

下面的代码可能会执行您想要的操作

# These assertions state the presumed effect of code that you have not included.
assert len(data1) == 10
assert d_chan == []
# I suspect a typo in the OP ... it makes more sense for the 
# two values below to be the same.
MIN_COL = 3
MAX_COL = 2
d_chan = [[0, 0] for i in xrange(9)]
min10 = min(data1[i][MIN_COL] for i in xrange(10))      
max10 = max(data1[i][MAX_COL] for i in xrange(10))
d_chan.append([max10, min10])

向我们显示一个
data1
。还有,
int(0)
?是的,肯定是一系列愚蠢的错误。。。data1是包含数字的列表列表。我最初尝试int(0),因为我无法解决浮点问题(现在有“x=0”)。代码应该迭代一定数量的数字以确定最大值和最小值。我使用一个简单的函数解决了这个问题。谢谢你的帮助-非常愚蠢的错误。我使用
x
作为数据1中的行:
作为获取len(数据1)中x的
的复杂方法