I have a list of 21 lists of 10 elements each, I want to get a new list of 21 lists of the 3 elements first elements of the previous ones.
Like if I have [[1,2],[3,4]]
and I wanted to get [1,3] (or [[1],[3]])
.
I know how to get this by a loop, but I would like to use a more compact way.
In python we can use a[:3]
for a simple list for example, but is there anyway to use something like a[:][:3] (like in MATLAB a(:,1:3))
to get inside the lists in the list?