Skip to main content

Another way to get the number of ocurrencesoccurrences of each item, in a dictionary:

dict((i, a.count(i)) for i in a) 

Another way to get the number of ocurrences of each item:

dict((i,a.count(i)) for i in a) 

Another way to get the number of occurrences of each item, in a dictionary:

dict((i, a.count(i)) for i in a) 
Source Link
tj80
  • 1k
  • 7
  • 2

Another way to get the number of ocurrences of each item:

dict((i,a.count(i)) for i in a)