Access item in a list of lists

list, python

Solution

You can access the elements in a list-of-lists by first specifying which list you're interested in and then specifying which element of that list you want. For example, `17` is element `2` in list `0`, which is `list1[0][2]`:

>>> list1 = [[10,13,17],[3,5,1],[13,11,12]]
>>> list1[0][2]
17

So, your example would be

50 - list1[0][0] + list1[0][1] - list1[0][2]

Problem

If I have a list of lists and just want to manipulate an individual item in that list, how would I go about doing that? For example: ``` List1 = [[10,13,17],[3,5,1],[13,11,12]] ``` What if I want to take a value (say 50) and look just at the first sublist in `List1`, and subtract 10 (the first value), then add 13, then subtract 17?

Original source