I have a dictionary of N items. Their values ββare strings, but I'm looking for an easy way to determine 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())
Depending on what you find more clear.
Try the following:
>>> d={'a':'', 'b':'', 'c':''} >>> any(map(bool, d.values())) False >>> d={'a':'', 'b':'', 'c':'oaeu'} >>> any(map(bool, d.values())) True
Source: https://habr.com/ru/post/1379997/More articles:How can I get the correct currency with 2 decimal places in C #? - regexMarshal C # Class Array as an array of structures for C - arraysConverting array contents to int - ruby ββ| fooobar.comattempt to create a matrix in ruby ββ- ruby ββ| fooobar.comFacebook application does not appear in search results - facebook-social-pluginsjsTree - Get selected node in load.jstree file - javascriptRunning `chmod` after installing a package using` setup.py` - pythonCSS print mode - Div at the bottom of the last page - htmlWhy can't I change the backcolor property at design time or runtime? - propertiesReflection in C # not working with COM (and C ++) - c ++All Articles