python how to add list to dictionary code example

Example 1: python dictionary of lists append

# Creating an empty dictionary 
myDict = {} 
  
# Adding list as value 
myDict["key1"] = [1, 2] 
  
# creating a list 
lst = ['Geeks', 'For', 'Geeks'] 
  
# Adding this list as sublist in myDict 
myDict["key1"].append(lst) 

# Print Dictionary
print(myDict)

Example 2: how to add an item to a dictionary in python

a_dictonary = {}
a_dictonary.update({"Key": "Value"})

Example 3: python dictionary with list

dictionary = {"one": [1, 2, 3, 4, 5], "two": "something"}
print(dictionary["one"][2])


3