How to merge two lists into a dictionary

Submitted 3 years, 7 months ago
Ticket #156
Views 213
Language/Framework Python
Priority Low
Status Closed

I have two lists

​
L1=['NAME','AGE','EMAIL','GENDER']
L2=['SOUMYA','22','soumya22@gmail.com','female']

​

I want the output as :

{'NAME':'SOUMYA','AGE':'22','EMAIL':'soumya22@gmail.com','GENDER':'FEMALE'}

Submitted on Sep 12, 20
add a comment

1 Answer

Verified

Here we have to use zip() function to combine two lists

   The solution is:

L1=['NAME','AGE','EMAIL','GENDER']
L2=['SOUMYA','22','soumya22@gmail.com','female']
d=dict(zip(L1,L2))
print(d)

Output :

{'NAME': 'SOUMYA', 'AGE': '22', 'EMAIL': 'soumya22@gmail.com', 'GENDER': 'female'}

Submitted 3 years, 7 months ago


Latest Blogs