Python: Line break after every nth line split
<p>I want to force a line break after every 10 numbers or 9 nine splits on a txt file in python? How would I go about this? So say i have </p>

<pre><code>Input would be something like: 
40 20 30 50 40 40 40 40 40 40  
20 40 20 30 50 40 40 40 
20 40 20 30 50 40 40 40 40 20 20 20
20 20 20 
</code></pre>

<p>int a txt.file
   and output should be</p>

<pre><code>40 20 30 50 40 40 40 40 40 40  
20 40 20 30 50 40 40 40 
20 40 20 30 50 40 40 40 40 20
20 20 
20 20 20 
</code></pre>

<p>so essentially break after every 10 numbers, or 9 line splits </p>

<p>I have tried:</p>

<pre><code>with open('practice.txt') as f:

    for line in f:
         int_list = [int(num) for num in line.split() ]
         if len(int_list) &lt; 20:
            print(int_list)
         else: 

             new_list = int_list[20:]
             int_list = int_list[:20]
             print(int_list)
             print(new_list)
</code></pre>

<p>But this doesn't quite solve it. Also note that the line lengths can vary. So the first line could have 5 numbers and the second line have 9 and the third 10 and the fourth 10</p>

<p>How about using [count] to count the occurrences of an item in the list?</p>

<pre><code>list == [40, 20, 30, 50, 40, 40, 40, 40, 40, 40, 20]
for i in list:
    if list.count(i) &gt; 10:
        # Do Stuff
</code></pre>

python