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
|
384 Discussions
|
Please Login in order to post a comment
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.import numpy as np
user_list = list(map(int,input().split()))
print(np.reshape(user_list,(3,3)))
Here is HackerRank Shape and Reshape in Python solution - https://programmingoneonone.com/hackerran-shape-and-reshape-problem-solution-in-python.html