Assign value to multiple slices in numpy
arrays, matlab, numpy, python, slice
Solution
a = np.arange(10)
a[[range(3)+range(6,9)]] = 10
#or a[[0,1,2,6,7,8]] = 10
print a
that should work I think ... I dont know that its quite what you want though
Problem
In Matlab, you can assign a value to multiple slices of the same list: ``` >> a = 1:10 a = 1 2 3 4 5 6 7 8 9 10 >> a([1:3,7:9]) = 10 a = 10 10 10 4 5 6 10 10 10 10 ``` How can you do this in Python with a numpy array? ``` >>> a = np.arange(10) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> a[1:3,7:9] = 10 IndexError: too many indices ```