Python program to count the frequency in a dictionary.

In this python dictionary program, we will count the frequency in a dictionary.

Steps to solve the program
  1. From collections import Counter.
  2. Take a dictionary as input.
  3. Pass the values in the dictionary to the Counter and store the result in a variable.
  4. Print the output.
				
					from collections import Counter
D1 = {'a':10,'b':20,'c':25,'d':10,'e':30,'f':20}    

result = Counter(D1.values())

print(result)
				
			

Output :

				
					Counter({10: 2, 20: 2, 25: 1, 30: 1})
				
			

find the shortest list of values with the keys in a given dictionary.

create key-value list pairings in a given dictionary.

Leave a Comment