Is there a simple way to index all elements of a list (or array, or whatever) except for a particular index? E.g.,
mylist[3]
The simplest way I found was:
mylist[:x] + mylist[x+1:]
that will produce your mylist without the element at index x.
mylist
x
mylist = [0, 1, 2, 3, 4, 5] x = 3 mylist[:x] + mylist[x+1:]
Result produced
mylist = [0, 1, 2, 4, 5]