I want to take 5 numbers from the user throught the input() and append them to a numpy array. I have the following code:
import numpy as np
X = [int(i) for i in input().split()]
X = np.array(X)
print(X)
When I run the above program I get the following output
[12345]
But if I have the following code
import numpy as np
X = np.array([1,2,3,4,5])
print(X)
I get the following output
[1 2 3 4 5]
I want to take input from the user using the input() and append it to a numpy array and when I use the print function on the array I get the above output. How can I do that in my code?
mahmoud988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.