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>I agree with @Neil It looks like you want a 2d array.  Here's another way to do it.</p>

<pre><code>from random import randint

my_list = [[randint(1, 11) for i in xrange(10)] for j in xrange(randint(5, 10))]
</code></pre>

<p>This will create a 0 - 9 number object 5 to 9 times. e.g [[2,3,4,5...], [1,2,2,3...]...]</p>

<p>Then you just iterate over the object to print it out the way you want</p>

<pre><code>for item in my_list:
  print item
</code></pre>

<p><strong>UPDATE</strong></p>

<p>Given the comment you replied with here is example of a random number file generator.</p>

<pre><code>from random import randint

#number of lines to create on the file
n = 3
with open('my_file.txt', 'w') as cout:
  for i in xrange(n):
    cout.write('{0}\n'.format(randint(1000, 10000))) #this is exclusive so it will only go as high as 9999
</code></pre>

<p>If you want more numbers on each line format the text inside the write method. E.G</p>

<pre><code>cout.write('{0}, {1}\n'.format(randint(1000, 10000), randint(1000, 10000)))
</code></pre>

python python-3.x while-loop