Matt Hoang1,517 Points
Removing a single value from a list in a list
Is it possible to remove an individual item from a list that is contained inside of a list?
For example, what if I had a list named my_list and set it equal to [1, 2, 3, [4, 5]]. It is possible to remove only the 4 or the 5? When I try to input a command such as my_list.remove(), it gives me the error: ValueError: list.remove(x): x not in list.
You would first have to access that interior list and then you could call the remove method on that list, passing in whichever value you wanted to remove.
That interior list is at index 3 within the outer list.
So you could access it with:
Then you can call the remove method on that.