How to count the number of zeros in each position of the sublist using python? -
i have 4 sublist in list below of length 38, want count number of 0 on each position. please how do it?
[[01100000100000000001100001001110100000],[01100000100000000001100001001110100000], [01100000100000000001100001001110100000], [01100000100000000001100001001110100000]]
the first index of 4 sublist 0000, hence number of 0 4. second index of 4 sublist 1111, hence number of 0 0. how want count 38 positions.
it's not clear question if numbers lists or strings. assuming they're strings (otherwise use bin()), i'd use zip() separate each position count() '0'
:
numbers = ['01100000100000000001100001001110100000', '01100000100000000001100001001110100000', '01100000100000000001100001001110100000', '01100000100000000001100001001110100000'] [digits.count('0') digits in zip(*numbers)]
Comments
Post a Comment