Convert given a dictionary to a list of tuples.

In this python dictionary program, we will convert given a dictionary to a list of tuples.

Steps to solve the program
  1. Take a dictionary as input.
  2. Convert the dictionary to a list of tuples using list() and items().
  3. Print the output.
				
					D1 = {'a':19,'b':20,'c':21,'d':20}
l = list(D1.items())
    
print(l)
				
			

Output :

				
					[('a', 19), ('b', 20), ('c', 21), ('d', 20)]
				
			

find all keys in the provided dictionary that have the given value.

create a flat list of all the keys in a flat dictionary.

Leave a Comment