You'd have to loop through the values:
if any('B' == value.upper() for value in d.itervalues()):
print 'Yup'
For Python 3, replace .itervalues()
with .values()
. This tests the minimum number of values; no intermediary list is created, and the any()
loop terminates the moment a match is found.
Demo:
>>> d = {3:'a',2:'b'}
>>> if any('B' == value.upper() for value in d.itervalues()):
... print 'Yup'
...
Yup