We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Shape and Reshape
- Discussions
Shape and Reshape
Shape and Reshape
Sort by
recency
|
387 Discussions
|
Please Login in order to post a comment
import numpy as np arr= np.array(list(map(int, input().split()))) shpa = arr.reshape(3,3) print(shpa)
import numpy a=list(map(int,input().split())) print(numpy.reshape(a,(3,3)))
My compact solution…
My solution shows another way to use
reshape
. The problem statement ony discussed reshaping by setting a value in theshape
property of an array object or by calling thenp.reshape()
function from the NumPy module. However, it is available as a method of array objects, too. Using that method, I was able to create the array and reshape it all in one line, using a fluent style of coding.