Concatenate

  • + 2 comments

    Python 3: Below code works fine: import numpy

    N, M, P = map(int, input().split())
    
    NP = numpy.array([input().split() for i in range(N)], int)
    MP = numpy.array([input().split() for j in range(M)], int)
    
    print(numpy.concatenate((NP, MP), axis = 0))
    

    Why is that writing the code in below fashion gives addresses and not the expected result?

    import numpy
    
    N, M, P = map(int, input().split())
    
    NP = numpy.array([map(int, input().split()) for i in range(N)])
    MP = numpy.array([map(int, input().split()) for j in range(M)])
    
    print(numpy.concatenate((NP, MP), axis = 0))
    

    Solution to above:

    [<map object at 0x7f4a5171d1d0> <map object at 0x7f4a516eb2b0>
    <map object at 0x7f4a516eb2e8> <map object at 0x7f4a516f0780>
    <map object at 0x7f4a516f0710> <map object at 0x7f4a49972da0>
    <map object at 0x7f4a4946d390>]