I have two lists a=[10,5,6,8]
and b=[1,3]
. How can I use the latter as a subscript of the former? I.e. I would like to extract the second and fourth element of a
.
Put otherwise, in Matlab I would use
v = [16 5 9 4 2 11 7 14];
v([1 5 6]) % Extract the first, fifth, and sixth elements
>> ans =
16 2 11
How can I do the same in Python?