Save python output into variable
<p>I have file with bitarray that looks like this:</p>

<pre><code>10000000000000000000000000000000000000000000000000000000000000000000001000000
</code></pre>

<p>I need to make a sum of bits according to their position in the bitarray: (second bit, second bit + 7, second bit + 14). I tried the code below, but it made a sum only of the first printed value. Can you please guide me on the problem?</p>

<pre><code>    lines = [line.strip() for line in open('test.txt')]
    bitp = range(1,len(lines[0]),7)
    for i in lines:
        for p in bitp:
            bitsum = sum(int(a) for a in i[p])
</code></pre>
