【发布时间】:2013-01-19 19:13:17
【问题描述】:
我试图定义一个函数,如果列表中的每个项目都小于 2,则返回 true,否则返回 false。项目的类型可以是与列表不同的整数、浮点数、str 或某物。我应该检查清单。
def ifeveryitems(lst):
for items in lst:
if isinstance(items,list) and len(items) <= 2:
return True and ifeveryitem(????) # '????' should be the items other than the item that has been searched #
else:
return False
【问题讨论】: