出于某种原因,我无法理解,使用最小和最大函数时发生TypeError。这是代码:随机导入从输入导入列表,任何,联合
list1 = []
for i in range(0,200):
x = random.randint(1,50)
list1.append(x)
list2 = [ j for j in range(0,51)]
list1.append(list2)
print(list1)
del list1[99:130]
print(len(list1))
print(min(list1))
这是错误:TypeError:'list'和'int'的实例之间不支持'
谢谢:)
因为您有嵌套列表
f = [12,3,4,5,[1,2,3]]
In [25]: min(f)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-25-d9448f4534d8> in <module>
----> 1 min(f)
TypeError: '<' not supported between instances of 'list' and 'int'