Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Created February 2, 2018 01:58
Show Gist options
  • Save Everfighting/d046a99d55956a77234569efd8fa7c9b to your computer and use it in GitHub Desktop.
Save Everfighting/d046a99d55956a77234569efd8fa7c9b to your computer and use it in GitHub Desktop.
count the every character in string
>>> string = 'hello world'
>>> { a:string.count(a) for a in set(string.replace(' ','')) }
{'h': 1, 'e': 1, 'w': 1, 'l': 3, 'o': 2, 'd': 1, 'r': 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment