Im taking an input processing it and storing it in a column format(4 * 1 array) and then putting this in a (4 * n np.zero array)..looping this to get n inputs
import numpy as np
l= int(input("enter the no. of elements"))
print ("enter the co-ordinates (X Y Z)-space seperated ")
i=0
inpf=np.zeros([4,(l)])
while(i<l):
inp1=np.array(input().split(" "))
inp2=[int(j) for j in inp1]
inp3=np.append(inp2,[1],axis=0)
inp=np.atleast_2d(inp3).T
inpf[:,i]=inp
i=i 1
print(inf)
This code isn't working (error- inpf[:,i]=inp ValueError: could not broadcast input array from shape (4,1) into shape (4,))
How do I solve this error ? How do I make the code more space efficient ?
Thanks
CodePudding user response:
try a simpler list approach
inp1=input().split(" ")
inp2=[int(j) for j in inp1]
inp2.append(1)
inpf[:,i]=inp2