cbbcbail
cbbcbail

Reputation: 1771

Accessing dictionary values that are lists of lists

How would I refer to a value inside of a list inside of a list that is the value of a particular term in a dictionary?

{value: [[1,2], []]}

How would I refer to the 1 in the example above to, for example += it?

Upvotes: 0

Views: 396

Answers (1)

sashkello
sashkello

Reputation: 17871

Just like to any other list element:

mydict['value'][0][0]

Think about it iteratively:

mydict['value'] is [[1,2], []]

To access the first element of that list you have:

mydict['value'][0] is [1,2]

Finally, the first element of your final list:

mydict['value'][0][0] is 1

Upvotes: 5

Related Questions