Counting vector elements with len

Assume we have the files generated from the subsection above. Then suppose we want to read a vector from a file and need to know how many elements we read. Here is an example:

>>> w = np.loadtxt("v.txt")
>>> print(w)
[ 1. -1.  1.]
n = len(w)
>>> print(n)
3

The function len gets the number of rows in the file. (The same len function works with standard Python objects, such as tuples and lists.)