Python reading only some lines of a text file : <p>I have text file like the following and what I would like to do it read three lines that start with 0 and three lines that start with 1 and so on until 30-40. And would like to print them on the same line. How could I accomplish this? Thank you very much!</p>

<pre><code>0 something
0 something2
0 something3
0 something4
0 something5
0 something6
1 something
1 something2
1 something3
1 something4
1 something5
1 something6
</code></pre>

<p>Desired output:</p>

<pre><code>0 something something2 something3
1 something something2 something3
</code></pre>
