可能重复:
Python:查找与谓词匹配的序列中的第一个元素
Python标准库中是否有封装以下控制流模式的高阶函数?
>>> def find(pred, coll):
... for x in coll:
... if pred(x):
... return x
...
>>> find(lambda n : n % 2 == 0, [3, 5, 8, 9, 6])
8
>>> find(lambda n : n % 2 == 0, [3, 5, 7, 9, 6])
6
>>> find(lambda n : n % 2 == 0, [3, 5, 7, 9, 1])