Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

lists to dictionary python

#This is to convert two lists into a dictionary in Python

#given ListA is key
#given ListB is value

listA = ['itemA','itemB']
listB = ['priceA','priceB']
dict(zip(listA, listB))

# Returns 
{'itemA': 'priceA',
 'itemB': 'priceB'
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #lists #dictionary #python
ADD COMMENT
Topic
Name
8+5 =