【发布时间】:2019-05-09 18:42:08
【问题描述】:
有没有一种方法可以轻松地将列表中的数字转换为单个数字,例如
population = ['10001','11111','11010','110001']
into ['1','0','0','0','1']
add each digit in each set and put it in another list like
this
evaluation = [2,5,3,3] (adding up all the 1's up on the first list)
我对 Python 很陌生,所以我不确定我是否正确地这样做了
【问题讨论】:
-
print(list(item.count('1') for item in population))
标签: python python-3.x