Newbie looking for elegant solution

otaksoftspamtrap at gmail.com otaksoftspamtrap at gmail.com
Tue Mar 24 23:13:56 EDT 2015


I have a list containing 9600 integer elements - each integer is either 0 or 1.

Starting at the front of the list, I need to combine 8 list elements into 1 by treating them as if they were bits of one byte with 1 and 0 denoting bit on/off (the 8th element would be the rightmost bit of the first byte).

The end result should be a new list that is 8 x shorter than the original list containing integers between 0 and 255.

Speed is not of utmost importance - an elegant solution is. Any suggestions?

Thanks for all input,
Kai



More information about the Python-list mailing list