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?
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)))
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?
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)))