create key in dictionary python code example
Example 1: how to set a key of dict in python
dictionary={'Hello':3,'World!':4}
def dict_add(obj,key,value):
obj[key]=value
reutrn obj
dict_add(dictionary,'Python',10)
print (dictionary)
Example 2: how to create dictionary in python
d = {'key': 'value'}
print(d)
d['mynewkey'] = 'mynewvalue'
print(d)
Example 3: append to dictionary python
languages = {'#1': "Python", "#2": "Javascript", "#3": "HTML"}
languages.update({"#4": "C#"})
languages['#4'] = 'C#'
Example 4: how to create a new dictionary in python
myDict = {'first item' : 'definition'}
myDict = {}