Python中列表所有元素的频率

Python中列表所有元素的频率,python,list,count,Python,List,Count,我有一个列表l=[1,2,2,3,1,1,2,3,4,5,6] 我不想使用l.count(element)方法。我不想使用for循环或迭代器。 像{1:3,2:3,3:2,4:1,5:1,6:1}这样的输出使用集合的计数器: >>> from collections import Counter >>> l = [1,2,2,3,1,1,2,3,4,5,6] >>> Counter(l) Counter({1: 3, 2: 3, 3: 2,

我有一个列表
l=[1,2,2,3,1,1,2,3,4,5,6]

我不想使用
l.count(element)
方法。我不想使用for循环或迭代器。

{1:3,2:3,3:2,4:1,5:1,6:1}这样的输出
使用集合的
计数器

>>> from collections import Counter
>>> l = [1,2,2,3,1,1,2,3,4,5,6]
>>> Counter(l)
Counter({1: 3, 2: 3, 3: 2, 4: 1, 5: 1, 6: 1})