Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: create spark dataframe from pandas 
Python :: discord py bot example 
Python :: create a new dataframe from existing dataframe pandas 
Python :: pd df drop columns 
Python :: get rid of unnamed column pandas 
Python :: np to tuple 
Python :: fibonacci number in python 
Python :: To View the entire Row and Column in a Dataframe 
Python :: armstrong python 
Python :: python subtract lists 
Python :: python how to convert csv to array 
Python :: python file parent 
Python :: python3 strip punctuation from string 
Python :: # convert dictionary into list of tuples 
Python :: django get group users 
Python :: Adjusting Subplot Margins in Matplotlib 
Python :: grid search cv 
Python :: scikit learn lda 
Python :: find index of maximum value in list python 
Python :: create a python3 virtual environment 
Python :: import time in python 
Python :: django cookies 
Python :: python square all numbers in list 
Python :: elon musk wikipedia 
Python :: groupby count pandas 
Python :: python count bits 
Python :: python remove punctuation from text file 
Python :: append path to sys jupyter notebook 
Python :: python nested list comprehension 
Python :: python generate random string 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =