In this python dictionary program, we will map two lists into a dictionary.
Steps to solve the program
- Take two lists as input.
- Map two lists into a single dictionary using zip() and dict().
- Print the output.
list1 = ['name','sport','rank','age']
list2 = ['Virat','cricket',1,32]
new_dict = dict(zip(list1,list2))
print(new_dict)
Output :
{'name': 'Virat', 'sport': 'cricket', 'rank': 1, 'age': 32}