How to Quickly Assign Letter Counts from Lists to Variables in Python
Question: Basically I have a list of (for all intents and purposes) random letters. The
letters are not really random, they do have significance; however, it really
isn't important for the question. The lists would look something like this:

    
    
    list = ['v', 'f', 't', 'w', 'w', 'i', 'b']
    

the real lists are significantly longer (up to 100 characters). I want to
count how many times each letter appears and assign that to a variable that is
that letter. For example:

    
    
    a = list.count('a')
    b = list.count('b')
    c = list.count('c')
    ...
    ...
    z = list.count('z')
    

I just want to know if there is a simpler way to do this instead of typing the
same line 26 times. I am running Python 3.4. I want to be able to do it in as
few lines and as few characters as possible. Any suggestions would be helpful,
thank you.


Answer: 
    import collections
    
    counts = collections.Counter(l)
    

`counts['a']` is then the number of occurrences of `a`. With a list of length
`L` and `N` possible different items, this runs in `O(L)` time instead of the
`O(NL)` a `list.count`-based solution would take, and it's less code.

