Once Twice Thrice Counting



Problem to find one number of occurence, two number of occurence and three number of occurence of each element in the list.



Example-1:


Input    : n = [ 1, 5, 7, 5, 3, 5, 7]
Output   : [2, 1, 1]
Explain  : One number of occurence values are 1 and 3.Two number of occurence value is 7.
           Three number of occurence value is 5.


Example-2:


Input    : n = [ 3, 9, 6, 6, 3]
Output   : [1, 2, 0]
Explain  : One number of occurence value is 9.Two number of occurence values are 6 and 3.
           There is no three number of occurence value.







Solution




n = [ 1, 5, 7, 5, 3, 5, 7]

a = list(set(n))

x = 0

y = 0

z = 0

for i in a:

    if(n.count(i) == 1):

        x += 1

    elif(n.count(i) == 2):

        y += 1

    elif(n.count(i) == 3):

        z += 1

b = [ x, y, z]

print(b)



Output



[2, 1, 1]