How to add a new line after each loop?
<p>Currently getting this output</p>

<pre><code>[1, 1, 3, '\n']
[1, 1, 3, '\n', 7, 7, 7, '\n']
</code></pre>

<p>looking for this output</p>

<pre><code>[1, 1, 3]
[7, 7, 7]
</code></pre>

<p>Code:</p>

<pre><code>    import random
    my_list=[]
    n = 3
    m = 1
    while m &lt; 10:
    for i in range(n): # repeats the following line(s) of code n times
        my_list.append(random.randrange(0,9))
    my_list.append("\n")
    print(my_list)
    m = m+1
</code></pre>

<p>Put the my_list=[] inside the outer loop to reinitialize it each time. Also, if you don't want the newline, don't append it to my_list. If you want all the output on the same line use the optional arg <code>end</code> to the print function.</p>

<pre><code>import random
n = 3
m = 1
while m &lt; 10:
    my_list = []
    for i in range(n):
        my_list.append(random.randrange(0,9))
    print(my_list, end="")
    m += 1
</code></pre>

python python-3.x while-loop