-3
     lst = ['10010001','01101001']

I need to count the number of times the number '1' appears in each element

3 Answers3

0
for element in lst:
    print element.count("1")
Sebastien D
  • 4,369
  • 4
  • 18
  • 46
0
>>> lst = ['10010001','01101001']
>>> [l.count('1') for l in lst]
[3, 4]
bla
  • 1,840
  • 1
  • 13
  • 17
-1
from collections import Counter
num_of_1s = [Counter(item)['1'] for item in lst]