Open this example in the interactive library
Source code
values = [3, 7, 11]
print(next((n for n in values if n > 20), None))Sample output
None

Take the first matching item with a fallback in Python.
Open this example in the interactive library
values = [3, 7, 11]
print(next((n for n in values if n > 20), None))None