Shape and Reshape

  • + 0 comments

    My compact solution…

    import numpy as np
    
    print(np.array(input().split(), int).reshape((3,3)))
    

    My solution shows another way to use reshape. The problem statement ony discussed reshaping by setting a value in the shape property of an array object or by calling the np.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.