I'm trying to get the number of the two elements that are the most frequent in an array. For example, in the list ['aa','bb','cc','dd','bb','bb','cc','ff']
the number of the most frequent should be 3
(the number of times 'bb' appear in the array) and the second most frequent 2
(number of times 'cc' appear in the array).
I tried this:
max = 0
snd_max = 0
for i in x:
aux=x.count(i)
if aux > max
snd_max=max
max=aux
print(max, snd_max)
But I was in doubt if there is an easier way?