Python - String Splitting
Question: Writing `'1000011'.split('1')` gives

    
    
    ['', '0000', '', '']
    

What I want is:

    
    
    ['1', '0000', '11']
    

How do I achieve this?


Answer: The `str.split(sep)` method does not add the `sep` delimiter to the output
list.

You want to _group_ string characters e.g. using
[`itertools.groupby`](https://docs.python.org/3/library/itertools.html#itertools.groupby):

    
    
    In:  import itertools
    
    In:  [''.join(g) for _, g in itertools.groupby('1000011')]
    Out: ['1', '0000', '11']
    

We didn't specify the `key` argument and the default `key` function just
returns the element unchanged. `g` is then the group of `key` characters.

