I have a list of dictionary, for example my given key value is ‘jerry’.
Is there a way to loop to the list and return only dictionary with the key value name of ‘jerry’?
lst= [{'name':'tom','score':5},{'name':'jerry','score':10},{'name':'jason','score':8}]
It should return
{'name':'jerry','score':10}
You can get all suitable elements with a generator expression and pick the first with
next: