Task
You are given a X integer array matrix with space separated elements ( = rows and  = columns).
Your task is to print the transpose and flatten results.
Input Format
The first line contains the space separated values of  and .
The next  lines contains the space separated elements of  columns.
Output Format
First, print the transpose array and then print the flatten.

hackerrank transpose and flatten problem solution in python programming

Problem solution in Python 3 programming language.

import numpy

N, M = map(int,input().split())

my_array = numpy.array( [map(int, input().split()) for i in range(N)] )
print(numpy.transpose(my_array))
print(my_array.flatten())

Second solution

import numpy
n, m = map(intinput().split())
array = numpy.array([input().strip().split() for _ in range(n)], int)
print (array.transpose())
print (array.flatten())

Problem solution in Python 2 programming language.

import numpy

N, M = map(int,raw_input().split())

my_array = numpy.array( [map(int, raw_input().split()) for i in range(N)] )
print numpy.transpose(my_array)
print my_array.flatten()