EXPERIMENT-12
Objective: To implement a program to map two lists into a dictionary.
Source code:
#map two strings into a dictionary
keys=['name','age','profession']
values=['ayush',20,'student']
mapped_dict=dict(zip(keys,values))
print("mapped dictionary1:", mapped_dict)
#using loop
mapped_dict1={}
for i in range(len(keys)):
mapped_dict1[keys[i]]=values[i]
print("mapped dictionary2:",mapped_dict1)
Input and output:
Conclusion: The experiment successfully implemented a program that maps two lists into a
dictionary. The program accurately pairs elements from the two lists, creating a dictionary
where one list’s elements serve as keys and the other’s as values.