84. Problem to create a dictionary with lists.

In this Python list program, we will take two user inputs as a list and create a dictionary with lists with the help of the below-given steps.

Create a dictionary with lists:

Steps to solve the program
  1. Take two lists as inputs.
  2. Combine those two lists using the zip function and converts the combined list into the dictionary.
  3. Print the dictionary to see the result.
				
					#Input lists
list1 = ["a", "b", "c", "d", "e"]
list2 = [234, 123, 456, 343, 223]  

#Combining lists and 
#Converting to dictionary
dictionary = dict(zip(list1,list2))

#Printing output
print(dictionary)
				
			

Output :

				
					{'a': 234, 'b': 123, 'c': 456, 'd': 343, 'e': 223}
				
			

Related Articles

List after removing n elements from both sides

Remove duplicate items from the list using set

Leave a Comment