Last active
October 4, 2016 12:55
-
-
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
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
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