I have a dictionary of N items. Their values are strings, but I'm looking for an easy way to detect if they are all empty strings.
{'a': u'', 'b': u'', 'c': u''}
not any(dict.itervalues())
Or:
all(not X for X in dict.itervalues())
Whichever you find clearer.
Try this:
>>> d={'a':'', 'b':'', 'c':''}
>>> any(map(bool, d.values()))
False
>>> d={'a':'', 'b':'', 'c':'oaeu'}
>>> any(map(bool, d.values()))
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With