Skip to content

Instantly share code, notes, and snippets.

@rfzeg
Created September 13, 2018 12:08
Show Gist options
  • Save rfzeg/32f26c4b43988db81ddb5c65ccd3ebe1 to your computer and use it in GitHub Desktop.
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
# 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