How do I access a certain list entry in a dictionary in python?

Viewed 53
thisdict = {
  "brand": "Ford",
  "model": [1,4,9,16],
  "year": 1964
}

print(thisdict.get("model"[1]))
2 Answers

Try simply indexing -

thisdict['model'][1]

OR

thisdict.get('model')[1]

When combining data structures, you must use each separately.

So, first get the list from the dict: thisdict["model"] or thisdict.get("model").

Then, use the list: thisdict.get("model")[1]

Related