Answers for "creating a dictionary in python"

6

how to create dictionary in python

# dictionary parameters
keys = ['a', 'b', 'c']
values = [1, 2, 3]
# create dictionary func.
def create_dictionary(keys, values):
    result = {} # empty dictionary
    for key, value in zip(keys, values):
        result[key] = value
    return result
# use create_dictionary func.
print(create_dic(keys=keys, values=values))

""" output:
{'a': 1, 'b': 2, 'c': 3}
"""
Posted by: Guest on August-04-2021
2

how to make dictionary in python

my_dict = {'key': 'value'}
Posted by: Guest on April-17-2021
1

how to create dictionary in python

d = {'key': 'value'}
print(d)
# {'key': 'value'}
d['mynewkey'] = 'mynewvalue'
print(d)
# {'key': 'value', 'mynewkey': 'mynewvalue'}
Posted by: Guest on October-08-2020
1

how to create dictionary in python from csv

input_file = csv.DictReader(open("coors.csv"))
Posted by: Guest on March-01-2020
2

how to create a new dictionary in python

myDict = {'first item' : 'definition'}
#CREATING A BLANK DICTIONARY
myDict = {}
Posted by: Guest on October-21-2020

Code answers related to "creating a dictionary in python"

Python Answers by Framework

Browse Popular Code Answers by Language