On 16 Okt., 02:18, Mensanator <mensana...@aol.com> wrote: > All I wanted to do is split a binary number into two lists, > a list of blocks of consecutive ones and another list of > blocks of consecutive zeroes.
Back to the OP's problem, the obvious (if you know the std lib) and easy solution is: >>> c = '001010111100101' >>> filter(None, re.split("(1+)", c)) ['00', '1', '0', '1', '0', '1111', '00', '1', '0', '1'] In production code, you compile the regex once, of course. -- http://mail.python.org/mailman/listinfo/python-list