""" How to convert 2 lists into a dictionary in python """
# list used for keys in dictionary
students = ["Angela", "James", "Lily"]
# list of values
scores = [56, 76, 98]
# convert lists to dictionary
student_scores = dict(zip(students, scores))
# print the dictionary
print(student_scores)
""" result should be
student_scores: -{
Angela: 56,
James: 76,
Lily: 98
},
"""
# Your Data list
names = ["john", "paul", "george", "ringo"]
job = ["guitar", "bass", "guitar", "drums"]
status = ["dead", "alive", "dead", "alive"]
dict_data = [{'name': name, 'job': job, 'status': status} for name,job,status in zip(names,jobs,statuses)]
keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print(dictionary) # {'a': 1, 'b': 2, 'c': 3}
# convert 2 list into dictionary
a = ['gsw','lakers','clippers']
b = [1,2,3]
my_dict = dict(zip(a,b))
print(my_dict) # {'gsw': 1, 'lakers': 2, 'clippers': 3}
d = {}
for i in list1:
for j in list2:
d[i] = j
print d
keys = tel.keys()
values = tel.values()
index = [1, 2, 3]
languages = ['python', 'c', 'c++']
dictionary = dict(zip(index, languages))
print(dictionary)