# Combining 'for'

I have the matrices:

```
x = lambda i: SR.var(f"x_{i}", latex_name=f"x_{{{i}}}")
a = matrix(2,2,[x(i) for i in [0 .. 3]]); A = matrix(4,4,[x(i) for i in [4 .. 19]])
```

And I would like to genarate four expressions with: j=0, j=1, j=2 and j=3

```
for j in (0..3):
e=[ x(j) - sum(A[j,i] for i in (0..1)) ]
e = -x_16 - x_17 + x_3
```

But the command above give me just the last one, i.e., -x_16 - x_17 + x_3. Any suggestions?

add a comment