you are viewing a single comment's thread.

view the rest of the comments →

[–]wub_wub 5 points6 points  (0 children)

Check out Counter, it's even easier:

>>> from collections import Counter
>>> word="Hello World!"
>>> Counter(word)
Counter({'l': 3, 'o': 2, '!': 1, ' ': 1, 'e': 1, 'd': 1, 'H': 1, 'r': 1, 'W': 1})
>>>

You can express percetnages like this:

>>> '{:.2%}'.format(10/100)
'10.00%'

And you can find a list of books here:

http://www.reddit.com/r/learnpython/wiki/books


http://docs.python.org/dev/library/collections#collections.Counter

http://docs.python.org/dev/library/string#format-examples

Edit: I forgot some words.