Home > Software design >  How can I create a vector of longitud len(x) numbered one by one from 0 to len(x) in python
How can I create a vector of longitud len(x) numbered one by one from 0 to len(x) in python

Time:09-09

I have a len(x), and need create a vector of that lenght (lenx), starting with a 0, so the last one should be len(x)-1.

how can I do this in python?

CodePudding user response:

I am not sure of what you mean by "vector", but I guess it is either of:

A Python list:

vector = [i for i in range(len(x))]

or

vector = list(range(len(x)))

A numpy array:

np.array(range(len(x)))
  • Related