Created
September 13, 2018 12:08
-
-
Save rfzeg/32f26c4b43988db81ddb5c65ccd3ebe1 to your computer and use it in GitHub Desktop.
Function to search list of dictionaries and return a selected value in selected dictionary
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
# Function to search list of dictionaries and return a selected value in selected dictionary | |
def search_dictionaries(key1, value1, key2, list_of_dictionaries): | |
selected_dic = [element for element in list_of_dictionaries if element[key1] == value1][0] | |
selected_val = selected_dic.get(key2) | |
return selected_val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment