如何计算python列表中单独列表中的数字?

use*_*564 1 python list

我如何计算3列表中出现的次数,例如[[1,2,3,4],[2,3,4,5],[5,6,7,5]] 输出应该是类似的[1,1,0]

Nic*_*las 6

您可以使用以下方法list.count(element):

my_lists = [[1,2,3,4], [2,3,4,5], [5,6,7,5]]
[l.count(3) for l in my_lists]
>> [1, 1, 0]
Run Code Online (Sandbox Code Playgroud)