Create a list of all the values in a dictionary. 

In this python dictionary, we will create a flat list of all the values 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 values of the dictionary.
  3. Add the values to the list using the append() function.
  4. Print the output.
				
					D1 = {'sqa':1,'tools':2,'is':3,'best':4} 
l = []

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

Output :

				
					[1, 2, 3, 4]
				
			

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

initialize a dictionary with default values

Leave a Comment