Convert a key-values list to a flat dictionary

In this python dictionary program, we will convert a key-values list to a flat dictionary.

Steps to solve the program
  1. Take a list having a list of values as input.
  2. Convert a key-values list to a flat dictionary using zip() and dict().

  3. Zip() will convert the list of values into a key-value pair.
  4. Print the output.
				
					dict1 = {'name':['Apr','May','June'],'month':[4, 5, 6]}

res = dict(zip(dict1['name'],dict1['month']))

print(res)
				
			

Output :

				
					{'Apr': 4, 'May': 5, 'June': 6}
				
			

filter a dictionary based on values.

convert a list of Tuples into a dictionary

Leave a Comment