python add to dictionary list 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 dictionary with list
dictionary = {"one": [1, 2, 3, 4, 5], "two": "something"}
print(dictionary["one"][2])
3