Turning a string into a list with specifications
Question: I want to create a list out of my string in python that would show me how many
times a letter is shown in a row inside the string. for example:

    
    
    my_string= "google"
    

i want to create a list that looks like this:

    
    
    [['g', 1], ['o', 2], ['g', 1], ['l', 1], ['e', 1]]
    

Thanks!


Answer: You could use
[groupby](http://docs.python.org/2/library/itertools.html#itertools.groupby)
from [itertools](http://docs.python.org/2/library/itertools.html):

    
    
    from itertools import groupby
    my_string= "google"
    [(c, len(list(i))) for c, i in groupby(my_string)]
    

