Every line of 'python search in list' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
5 def _find_dict_in_list(list_of_dict, key, val): 6 """Given a list of dictionaries, return the first dictionary that has the 7 given key:value pair. 8 """ 9 try: 10 for d in list_of_dict: 11 if (key, val) in d.items(): 12 return d 13 except TypeError: 14 pass
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code