Question: I have post the similar question before,but this time the problem is different,I got stuck with the following code..can anyone help with it?thanks in advance

I have fixed mu code as suggested,thanks

```
from numpy import *
#vs,fs,rs are all m*n matrixs,got initial values in,i.e vs[0],fs[0],rs[0] are known
#want use this foor loop to update them
vs=zeros((10,3))
vs[0]=([1,2,3])
fs=zeros((10,3))
fs[0]=([2,3,4])
vs=zeros((10,3))
vs[0]=([3,4,5])
for i in range(5):
    #start looping..
    vs[i+1]=vs[i]+fs[i]
    fs[i+1]=(rs[i]-re[i])
    rs[i+1]=rs[i]+vs[i]
print vs,fs,rs

```

then this code gives vs,fs,rs in different i,but not update each rows of rs,fs,vs and return me a single array of rs,fs,vs (fully updated). whats the problem here?..what should I add?thanks

Answer: 
Put your inizialization **outside** the loop! Right now, you're resetting the arrays to all zeros **each time through the loop**, over and over, which is absurd. You also appear to have a typo -- you set vs twice and rs never -- so I've tried to guess what you meant.

```
from numpy import *

#vs,fs,rs are all m*n matrixs,got initial values in,i.e vs[0],fs[0],rs[0] are known
#want use this foor loop to update them
vs=zeros((10,3))
vs[0]=([1,2,3])
fs=zeros((10,3))
fs[0]=([2,3,4])
rs=zeros((10,3))
rs[0]=([3,4,5])

for i in range(5):
    #start looping..
    vs[i+1]=vs[i]+fs[i]
    fs[i+1]=rs[i]-re[i]
    rs[i+1]=rs[i]+vs[i]
    print vs,fs,rs

```
I don't know exactly what you want to print. If you want to print every matrix every time it is updated, then you're fine. But if you want to print the matrices after all the updates have been completed, then you should bring that print statement out of the for loop.

This and what Alex and sth have said should fix your code fully