I try to capture multiple IndexErrors in the same loop, yet I can only capture the first one. This question might be related to my question, yet I cannot understand it. If it helps, I am using Enthought Canopy 1.6.2 on Windows 10 and Python 2.7.13.
import numpy as np
some_array=np.zeros(10)
some_set=[2,4,15,19]
for sense in some_set:
try:
some_array[sense]=1
except IndexError:
some_set.remove(sense)
print some_set, "sense"
The output I receive is:
[2, 4, 19] sense
While I want an output of the form
[2, 4, 19] sense
[2, 4] sense