import numpy
n,m=map(int, input().split())
arr=numpy.array([input().strip().split() for _ in range(n)],int)
print (numpy.transpose(arr))
print(arr.flatten())
Why should there be an underscore before "in range" in the third line? It would also be useful if someone explained why .strip and .split need to be applied here.
Thanks a lot!
>Solution :
_ is just a variable, it could be named differently, for example i. _ is just a conventional name for unused variables. In this case, you execute input().strip().split() n times in exactly the same way, without caring which iteration (i) it is.
.split() splits the input string by spaces, for example:
>>> '1 2 3'.split()
['1', '2', '3']
.strip() trims whitespace at the edges:
>>> ' 1 2 3 '.strip()
'1 2 3'
You can read more about these methods by googling the docs or, even simpler, running help(str.split) in an inerpreter