Computer Science, asked by 9849998706, 1 year ago

Write a program that combines the lists to a dictionary?

Answers

Answered by Shashank1811
0

Python Exercise: Map two lists into a dictionary.

Write a Python program to map two lists into a dictionary.

Sample Solution:-

Python Code:

keys = ['red', 'green', 'blue'] values = ['#FF0000','#008000', '#0000FF'] color_dictionary = dict(zip(keys, values)) print(color_dictionary)

Sample Output:

{'green': '#008000', 'blue': '#0000FF', 'red': '#FF0000'}

Shashank1811: is this helpful to u??
Answered by PiyushRaj1
0

keys = ['red', 'green', 'blue']
values = ['#FF0000','#008000', '#0000FF']
color_dictionary = dict(zip(keys, values))
print(color_dictionary)

Sample Output:

{'green': '#008000', 'blue': '#0000FF', 'red': '#FF0000'}
Python Code Editor:

Shashank1811: u copied me
PiyushRaj1: no u copied me
PiyushRaj1: u copied from internet
Shashank1811: i wrote it before u
Shashank1811: so it means u copied..
Similar questions