dict.set python code example

Example 1: Python dictionary append

# to add key-value pairs to a dictionary:

d1 = {
	"1" : 1,
	"2" : 2,
  	"3" : 3
} # Define the dictionary

d1["4"] = 4 # Add key-value pair "4" is key and 4 is value

print(d1) # will return updated dictionary

Example 2: dictionary in python

thisdictionary = {'key':'value','key1':'value1'}
print(thisdictionary['key'])

Example 3: python dictionary value as set

word_dict = dict()
word_dict["foo"] = set()
word_dict["foo"].add("baz")                                    
word_dict["foo"].add("bang")