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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -