I have a list of dicts e.g.
[{\'name\':\'Bernard\',\'age\':7},{\'name\':\'George\',\'age\':4},{\'name\':\'Reginald\',\'age\':6}]
I\'d like to c
There is a much more efficient way to do this than with looping. If you use operators.itemgetter
you can do a simple if x in y check
#to simply check if the list of dicts contains the key=>value pair
'George' in map(itemgetter('name'), list_of_dicts)
#if you want to get the index
index = map(itemgetter('name'), list_of_dicts).index("George") if 'George' in map(itemgetter('name'), list_of_dicts) else None