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
- Take two lists as inputs.
- Combine those two lists using the zip function and converts the combined list into the dictionary.
- 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
Python program to remove the duplicate item from the list using set.
Python program to insert a sublist into the list at a specific index.
Python program to calculate the bill per fruit purchased from a given fruits list.
Python program to calculate percentage from a given mark list, the max mark for each item is 100.
Python program to get the list of all palindrome strings from the given list.
Python program to flatten a given nested list structure.