I want test whether a string is present within any of the list values in a defaultdict.
For instance:
from collections import defaultdict
animals = defaultdict(list)
animals['farm']=['cow', 'pig', 'chicken']
animals['house']=['cat', 'rat']
I want to know if 'cow' occurs in any of the lists within animals.
'cow' in animals.values() #returns False
I want something that will return "True" for a case like this. Is there an equivalent of:
'cow' in animals.values()
for a defaultdict?
Thanks!