Answers for "append a list in a dictionary python"

3

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)
Posted by: Guest on June-22-2020
2

list of dictionary values

d.values()
Posted by: Guest on March-10-2020

Code answers related to "append a list in a dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language