Last active
May 23, 2019 19:09
-
-
Save Estivales/ec8cdc3c43768061b5ecb49b5486159a to your computer and use it in GitHub Desktop.
How to find a value in a list of python dictionaries
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
list_of_dict = [{"name": "Douglas", "surname": "Estivales"}, | |
{"name": "Bruce", "surname": "Silva"}, | |
{"name": "Joaquim", "surname": "Teixeira"}, | |
{"name": "Mohammed", "surname": "Lee"}] | |
search_for_name = "Douglas" | |
result = next((l for l in list_of_dict if l['name'] == search_for_name), None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment