Python错误:无法订购的类型:list()<int()
我一直收到错误无法订购的类型:list()< int()。我做错了什么,我该如何解决?Python错误:无法订购的类型:list()<int()
我的代码:
import sys from List import *
def main():
strings=ArrayToList(sys.argv[1:])
numbers=ListMap(int,strings)
smallest=numbers[0]
for i in range(len(numbers)):
if numbers[i]<smallest:
smallest=numbers[i]
return smallest
print("The smallest is", smallest(numbers))
main()
错误:
Traceback (most recent call last): File "command.py", line 18, in <module>
main()
File "command.py", line 12, in main
if numbers[i]<smallest:
TypeError: unorderable types: list() < int()
回答:
貌似你试图比较整数的列表,这是不可能的Python3。确保numbers
的所有项目都是整数。
>>> [] < 1 Traceback (most recent call last):
File "<ipython-input-1-de4ae201066c>", line 1, in <module>
[] < 1
TypeError: unorderable types: list() < int()
以上是 Python错误:无法订购的类型:list()<int() 的全部内容, 来源链接: utcz.com/qa/259887.html