add item to dictionary list python 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: Python dict add item
# This automatically creates a new element where
# Your key = key, The value you want to input = value
dictionary_name[key] = value