Here is my question: I have a list in python that looks like this:
list = [["a", "b", [1,2]], ["a", "C", [4,1,3]], ["e", "f", [1,7]]]
And I would like to get a sublist like this:
sublist = [[1,2], [4,1,3], [1,7]]
I would like to know if there is a quick way to make this transition,
Thank you in advance for your help 🙂
>Solution :
Don’t use list as a name for a list as it clashes with the built-in name. Use this:
l = [["a", "b", [1,2]], ["a", "C", [4,1,3]], ["e", "f", [1,7]]]
sublist = [i[-1] for i in l]
Output:
[[1, 2], [4, 1, 3], [1, 7]]