Write a Python program to sum of all counts in a collections

example :- 2,4,1,4,6,6,2
output:-7

code:-
import collections
num = [3,5,32,2,1,4,5,9]
print(sum(collections.Counter(num).values()))
output:-
8
>>> 

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post