In matlab one can do
for i = 2:10
array(i) = array(i-1) + value
end
How can I replicate this in python?
In matlab one can do
for i = 2:10
array(i) = array(i-1) + value
end
How can I replicate this in python?
In python it will be:
for i in range(1,10):
array[i] = array[i-1] + value
Keep in mind that in python
, indexing starts from 0
.
You can do something like this in python:
But you should also pay attention to one point: That the number of indexes in Python starts from zero while in MATLAB from one
for i in range(2,10):
array[i] = array[i-1] + value
have a good time!