Shape and Reshape

Sort by

recency

|

373 Discussions

|

  • + 0 comments

    import numpy import sys

    chars = sys.stdin.read().split() arr = numpy.array([int(char) for char in chars]) arr.shape = (3,3) print(arr)

  • + 0 comments

    import numpy

    arr=list(map(int,input().split()))

    change_array=numpy.array(arr) change_array=change_array.reshape(3,3) print(change_array)

  • + 0 comments

    With the help of regEx :

    import sys, re, numpy
    
    entry = sys.stdin.read().splitlines()
    
    for line in entry:
        print(numpy.array([int(i) for i in re.findall(r"\d", line)]).reshape(3, 3))
    
  • + 0 comments

    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)

  • [deleted]Challenge Author
    + 0 comments

    For Python3

    import numpy
    
    lst = [*map(int, input().split())]
    arr = numpy.array(lst)
    print(numpy.reshape(arr, (3, 3)))