Is it possible to compute the following using single where condition in Python. I'm unable to do that.
x = np.arange(10)
If an element of x is smaller than 3, replace it with 3. And if an element of x is bigger than 7, replace it with 7.
My attempt is as follows, however I'm wondering if it could be done in a single line of code
x= np.where(x<3 ,3,x)
x = np.where(x>7,7,x)
Sorry, if it seems very basic. But I have just started with numpy
numpy.clip().