Skip to content

Instantly share code, notes, and snippets.

@Hammer2900
Created June 6, 2015 19:24
Show Gist options
  • Save Hammer2900/f0e6039862ade4d15812 to your computer and use it in GitHub Desktop.
Save Hammer2900/f0e6039862ade4d15812 to your computer and use it in GitHub Desktop.
If you want to find one element or None
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