【发布时间】:2018-03-17 14:36:56
【问题描述】:
#Basically, for the input number given, return results that are smaller
#than it compared with the list.
n = list(input('Please enter a Number: '))
#map(int, str(n))
newlist = []
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
for n in a:
if n > a:
newlist.append(a)
print(newlist)
不要求解决方案,而只是询问 n 如何作为列表工作,因为当我运行我的代码时,它说:
" if n > a:
TypeError: '>' not supported between instances of 'int' and 'list' "
【问题讨论】:
标签: python python-3.x list input