import numpy as np
arr = list(map(float,input().split()))
# outputs "<built-in method reverse of list object at 0x107eeeec8>"
You have two problems.
The first problem is that you are not actually calling the reverse method on your array
You have this:
You have to actually call it ->
Simple example below:
>>> [1,2,3].reverse <built-in method reverse of list object at 0x100662c68>
reverse, the output you get is the uncalled reverse method of the
list object. Which is very similar to the output you were getting.
The second problem you have is that
reverse() method does the reverse in place, which means it performs the reverse on
arr (your arr will be reversed) and returns
None. So, when you are passing this:
You are returning the return of
arr.reverse() to your
np.array call, which is
So, fixing those two items, by calling
arr.reverse() on its on, and then passing
arr, will give you the result you are expecting:
import numpy as np arr = list(map(float,input().split())) arr.reverse() res = np.array(arr) print(res)
1 2 3 4 [ 4. 3. 2. 1.]