我一直收到错误无法解决的类型: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()
答案 0 :(得分:1)
看起来你正在尝试将列表与整数进行比较,这在Python3中是不可能的。确保numbers
的所有项都是整数。
>>> [] < 1
Traceback (most recent call last):
File "<ipython-input-1-de4ae201066c>", line 1, in <module>
[] < 1
TypeError: unorderable types: list() < int()