Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Created February 28, 2017 10:04
Show Gist options
  • Save pmgupte/f1d10b5992013551217033d25f700506 to your computer and use it in GitHub Desktop.
Save pmgupte/f1d10b5992013551217033d25f700506 to your computer and use it in GitHub Desktop.
Python code to check if all the values in dictionary are zero.
d = {'a': 0, 'c': 0, 'b': 0, 'd': 0}
l = d.values()
s = set(l)
if len(s) == 1 and list(s)[0] == 0:
print "all 0"
else:
print "not all 0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment