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
- Transpose and Flatten
- Discussions
Transpose and Flatten
Transpose and Flatten
Sort by
recency
|
320 Discussions
|
Please Login in order to post a comment
import numpy as np
n,m = input().split() arr = [] for i in range(int(n)): num = list(map(int, input().split())) arr.append(num) myarr = np.array(arr) print(np.transpose(myarr)) print(myarr.flatten())
MY SOLUTION
import numpy n,m = list(map(int,input().split())) l = [] for i in range(n): b= list(map(int,input().split())) l.append(b)
a = numpy.array(l) print(numpy.transpose(a)) print(a.flatten())
import numpy as np
rows, cols = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(rows)]
arr = np.array(arr, dtype=int)
print(np.transpose(arr))
print(arr.flatten())
Simple Noobie approach -