Skip to content

Instantly share code, notes, and snippets.

@tchiavegatti
Created September 25, 2020 17:08
Show Gist options
  • Save tchiavegatti/0370a935b3442be5b3d16c97287e2644 to your computer and use it in GitHub Desktop.
Save tchiavegatti/0370a935b3442be5b3d16c97287e2644 to your computer and use it in GitHub Desktop.
[Counter] Count values in a list
from collections import Counter
lst = [4, 3, 3, 2, 4, 3]
print(Counter(lst))
Counter({3: 3, 4: 2, 2: 1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment