python - Creating a list from user input using a for loop -
i trying make loop in python user input array 5 times , store them each 1 5 in a[i],but code didn't work.here code :
import numpy numpy import linalg import numpy np in range(5): u[i]=np.array(input(" ")) print u[i]
first, need tell python u going list. otherwise u[i] throw nameerror because you're trying access u without having defined it.
then, need grow list dynamically, otherwise u[i] throw indexerror because, again, you're trying reference u[i] before has been created.
import numpy np u = [] in range(5): u.append(np.array(input(" "))) print u[i]
Comments
Post a Comment