我不知道如何在不使用复杂功能的情况下做到这一点,请帮忙。这是代码的文档字符串:
'''
finds all numbers in the list below a certain threshold
:param numList: a list of numbers
:threshold: the cutoff (only numbers below this will be included)
:returns: a new list of all numbers from numList below the threshold
'''
答案 0 :(得分:0)
一种方法
def filterList(numList, threshold):
return list(filter(lambda x: x < threshold, numList))
另一种方法:
filteredList = [x for x in numList if x < threshold]