Skip to content

Combine two lists into a dictionary in Python

Advertisements

Combines two lists into a dictionary, where the elements of the first one serve as the keys and the elements of the second one serve as the values.

print(dict(zip(['name','age','sex'],['Anand','26','M'])))

#{'age': '26', 'name': 'Anand', 'sex': 'M'}

See also  Removing duplicates from an array in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.