a splitting headache

Mensanator mensanator at aol.com
Sat Oct 17 10:08:34 CEST 2009


On Oct 16, 11:41�pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Mensanator <mensana... at aol.com> writes:
> > Thanks, but what I wanted was
> > ['00','1','0','1','0','1111','00','1','0' '1'].
>
> � � >>> c = '001010111100101'
> � � >>> list(''.join(g) for k,g in groupby(c))
> � � ['00', '1', '0', '1', '0', '1111', '00', '1', '0', '1']
>
> is really not that unnatural.

I thought someone else had suggested this solution earlier.
Oh yeah, some guy named Paul Rubin. At first, I thought I
needed to keep the 1's and 0's in seperate lists, but now that
I see this example, I'm rethinking that.

Thanks, and thanks to Paul Rubin.




More information about the Python-list mailing list