The following code is derived from a past question on this site found here --> How to add multiple values to a dictionary key in python? This code allows you to assign multiple values to a key in a dictionary. I have tried several ways to use the .get
method to return a specified list value using a dictionary key but nothing has worked so far. If this question has already been asked before please show me to the correct thread. I have not found anything on this so far. Any help is appreciated.
a = {}
a["abc"] = [1, 2, "bob"]
print(a.get("abc")) # this prints [1, 2, 'bob']
print(a.get("abc"[1])) #this is an example of one of the things that I tried. Prints None
Expected output from print(a.get("abc"[1]))
:
2
Actual output:
None