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
|
373 Discussions
|
Please Login in order to post a comment
import numpy import sys
chars = sys.stdin.read().split() arr = numpy.array([int(char) for char in chars]) arr.shape = (3,3) print(arr)
import numpy
arr=list(map(int,input().split()))
change_array=numpy.array(arr) change_array=change_array.reshape(3,3) print(change_array)
With the help of regEx :
import numpy as np """ list() # use to create list map # use to apply a integer function to all iterables items int # the fuction convert input into integer like number np.array() ##### to convert list into array """ array=np.array(list(map(int,input().split()))).reshape(3,3) print(array)
For Python3