Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create and populate dictionary python

# empty dictionary
dictionary = {}
# lists
list_1 = [1, 2, 3, 4, 5]
list_2 = ["a", "b", "c", "d", "e"]
# populate a dictionary.
for key, value in zip(list_1, list_2):
    dictionary[key] = value
# output
print(dictionary)
 
PREVIOUS NEXT
Tagged: #create #populate #dictionary #python
ADD COMMENT
Topic
Name
2+4 =