How can I loop through a list changing the list elements at each time step, adding or subtracting input values that are in the txt files?
<p>Why don´t I get the following result, in this order?
[-2.0, -1.0, 0.0, 1.0, 2.0]
[-1.0, 0.0, 1.0, 2.0, 3.0]
[-2.0, -1.0, 0.0, 1.0, 2.0], instead i get the second list in the wrong place.
Can I edit list elements in a more consistent way, considering this form of input data?
My objective is to change a initial list (V) at each time step, adding or subtracting the input values that are in the txt files.</p>

<pre><code>V = [1,2,3,4,5]

f = open('Qin.txt')     # values in Qin.txt: 1, 3, 2 
g = open('Qout.txt')    # values in Qout.txt: 4, 5, 5 

for line in f:
    Z=float(line)

for line in g:
    G=float(line)
    c = []
    for i in range(len(V)):
    c.append(V[i]+Z-G)

print c
</code></pre>
