In this python dictionary program, we will show a dictionary with a maximum count of pairs.
Steps to solve the program
- Take two dictionaries as input.
- Count the key-value pairs in both dictionaries using the len() function.
- Compare them by using ‘ > ‘ or ‘ < ‘.
- 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