Find maximum and minimum values in a dictionary.

In this python dictonary program, we will find maximum and minimum values in a dictionary.

Steps to solve the program
  1. Take a dictionary as input and create an empty list.
  2. Use for loop to iterate over values in the dictionary using values().
  3. Add the values to the empty list.
  4. Sort the list by using sort().
  5. Find the maximum and minimum values by using logic.
  6. Print the output.
				
					dict1 = {'a':10,'b':44,'c':60,'d':25}
list1 = []

for val in dict1.values():
    list1.append(val)
    
list1.sort()

print("Minimum value: ",list1[0])
print("Maximum value: ",list1[-1])
				
			

Output :

				
					Minimum value:  10
Maximum value:  60
				
			

map two lists into a dictionary.

group the same items into a dictionary values.

Leave a Comment