-3

lets say we have this array:

Sample_array = [1,2,4,4,5,1,2,4]

and we want to know how many times each element occurs in this array, without using numpy what is the easiest and simplest way to do it?

1 Answers1

1

You can use an internal python library named Counter like below:


from collections import Counter                                                                                                                        

Counter(Sample_array)                                                                                                                                  
Counter({1: 2, 2: 2, 4: 3, 5: 1})
oppressionslayer
  • 6,942
  • 2
  • 7
  • 24