Created
June 6, 2015 19:24
-
-
Save Hammer2900/f0e6039862ade4d15812 to your computer and use it in GitHub Desktop.
If you want to find one element or None
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lst = [1,2,3] | |
first_or_default = next((x for x in lst if x == 10), None) | |
print first_or_default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment