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'}