1# dictionary parameters
2keys = ['a', 'b', 'c']
3values = [1, 2, 3]
4# create dictionary func.
5def create_dictionary(keys, values):
6 result = {} # empty dictionary
7 for key, value in zip(keys, values):
8 result[key] = value
9 return result
10# use create_dictionary func.
11print(create_dic(keys=keys, values=values))
12
13""" output:
14{'a': 1, 'b': 2, 'c': 3}
15"""
1#title : Dictionary Example
2#author : Joyiscold
3#date : 2020-02-01
4#====================================================
5
6thisdict = {
7 "brand": "Ford",
8 "model": "Mustang",
9 "year": 1964
10}
11
12#Assigning a value
13thisdict["year"] = 2018
1thisdict = {
2 "key1" : "value1"
3 "key2" : "value2"
4 "key3" : "value3"
5 "key4" : "value4"
6}
1d = {'key': 'value'}
2print(d)
3# {'key': 'value'}
4d['mynewkey'] = 'mynewvalue'
5print(d)
6# {'key': 'value', 'mynewkey': 'mynewvalue'}
7