Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active July 10, 2020 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/ce00e45053e1a077b0e2789d16d0d10c to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/ce00e45053e1a077b0e2789d16d0d10c to your computer and use it in GitHub Desktop.
from collections import Counter
#Unary addition removes zero and negative count
c=Counter({'a':1,'b':2,'c':-5})
print (+c)#Output:Counter({'b': 2, 'a': 1})
#unary subtraction
c1=Counter({'a':1,'b':2,'c':-5})
print (-c)#Output:Counter({'c': 5})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment