Show a dictionary with a maximum count of pairs.

In this python dictionary program, we will show a dictionary with a maximum count of pairs.

Steps to solve the program
  1. Take two dictionaries as input.
  2. Count the key-value pairs in both dictionaries using the len() function.
  3. Compare them by using ‘ > ‘ or ‘ ‘.
  4. Print the respective output.
				
					A = {'name':1,'age':2}
B = {'name':1,'age':2,'course':3,'institute':4}

count_a = len(A)
count_b = len(B)

if count_a > count_b:
    print("1st dicyionary has maximum pairs",count_a)
else:
    print("2nd dicyionary has maximum pairs",count_b)
				
			

Output :

				
					2nd dicyionary has maximum pairs 4
				
			

retrieve the value of the nested key indicated by the given selector list from a dictionary or list.

Extract Unique values from dictionary values.

Leave a Comment