1
>>> my_list = [{u'name': u'name1', u'color': u'red'}, {u'name': u'name2', u'color': u'blue'}]
>>> my_list[0]
{u'color': u'red', u'name': u'name1'}
>>> my_list[1]
{u'color': u'blue', u'name': u'name2'}

How can I filter from my_list dict that contains 'color': u'blue'?

0

1 Answer 1

3

Iterate over the list and find the item which has blue as color key value.

next(i for i in my_list if i['color'] == 'blue')

Not the answer you're looking for? Browse other questions tagged or ask your own question.