searching a list of dictionaries for an element in a list.

Odd-R. oddr at
Wed Aug 10 11:54:26 CEST 2005

If input is ['red','blue'],
list1 is [	{'primarycolor':'red', 'secondarycolor':'burgundee'},
		{'primarycolor':'red', 'secondarycolor':'wine'},

I want to search list1, and the result should be all dictionaries where
primarycolor is in input. I can do this using a double for-loop, but is
there a more efficent way?

Har du et kjøleskap, har du en TV
så har du alt du trenger for å leve

-Jokke & Valentinerne

More information about the Python-list mailing list