Create a list of all the keys in a dictionary.

In this python dictionary program, we will create a flat list of all the keys in a flat dictionary.

Steps to solve the program
  1. Take a dictionary as input and create an empty list.
  2. Use for loop to iterate over keys of the dictionary.
  3. Add the keys to the list using the append() function.
  4. Print the output.
				
					D1 = {'sqa':[1,2,5,6],'tools':[3,8,9],'is':[2,5,0],'best':[3,6,8]} 
l = []

for k in D1.keys():
    l.append(k)
    
print(l)
				
			

Output :

				
					['sqa', 'tools', 'is', 'best']
				
			

convert given a dictionary to a list of tuples.

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

Leave a Comment