W
wcc
Hello,
Beginner learning Python here. I know filter(lambda x: x > 3, [1, 2,
5, -3, 4, 8]) will give me a list [5, 4, 8]. What if I only need to
find the first item in the list that returns Ture when applying the
filter function. In this case, I only want to get the 5, and its index
2. Is there a built-in function, or function from a module for that?
I think it is not hard to write a function for this. But knowing
Python is "battery included", I thought I'd like to ask. Thanks for
your help.
- wcc
Beginner learning Python here. I know filter(lambda x: x > 3, [1, 2,
5, -3, 4, 8]) will give me a list [5, 4, 8]. What if I only need to
find the first item in the list that returns Ture when applying the
filter function. In this case, I only want to get the 5, and its index
2. Is there a built-in function, or function from a module for that?
I think it is not hard to write a function for this. But knowing
Python is "battery included", I thought I'd like to ask. Thanks for
your help.
- wcc