Skip to content

Instantly share code, notes, and snippets.

@thomasvnl
Last active October 4, 2016 12:55
Show Gist options
  • Save thomasvnl/b0d1bff0b6600b070512849e0d4fe2db to your computer and use it in GitHub Desktop.
Save thomasvnl/b0d1bff0b6600b070512849e0d4fe2db to your computer and use it in GitHub Desktop.
Return an item from a list of dictionaries by comparing key:value combination
def get_item_from_dict_list_by_key_value(list, key, value):
"""
Return an item from a list by key:value combination if possible
:param list list:
:param str key:
:param * value:
:return dict|None:
"""
for item in list:
if item[key] == value:
return item
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment