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

Question:

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?

Asked By: boxertrain

||

Answers:

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)))
Answered By: Greg
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.