I have an integer list that should be used as indices of another list to get the value. Let's say we have an array
a = [1,2,3,4,5,6,7,8,9]
We can get specific elements using the following code
import operator operator.itemgetter(1,2,3)(a)
He will return the 2nd, 3rd and 4th positions.
Let's say I have another list
b=[1,2,3]
But if I try to run the following code, it will get an error message
operator.itemgetter(b)(a)
I am wondering if anyone can help me. I think this is just the problem that I need to convert the value of b to a comma, but not necessarily.
thanks a lot
source share