I have the following dictionary:
dictionary = {'A':0, 'B':0, 'C':0, 'D':0}
I would like to check if all the values stored by the dictionary keys are zero and then execute some code. What I had in mind is something like:
if (dictionary[k] == 0 for all k in dictionary.keys()):
# do something
What I am currently doing is:
if (dictionary['A'] == 0 and dictionary['B'] == 0 and dictionary['C'] == 0 and dictionary['D'] == 0):
# do something
This seems very inefficient if my dictionary grows larger. Is there any way I could check a condition for all keys and demand all of them to be simultaneously true?