0% found this document useful (0 votes)
26 views1 page

EXPERIMENT12

The document outlines an experiment to create a dictionary by mapping two lists: one containing keys and the other containing values. It provides source code examples using both the zip function and a loop to achieve this mapping. The conclusion confirms the successful implementation of the program, accurately pairing elements from the lists.

Uploaded by

Ayush Gautam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

EXPERIMENT12

The document outlines an experiment to create a dictionary by mapping two lists: one containing keys and the other containing values. It provides source code examples using both the zip function and a loop to achieve this mapping. The conclusion confirms the successful implementation of the program, accurately pairing elements from the lists.

Uploaded by

Ayush Gautam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like