I'm struggling to write numbers (0-10) into a CSV file. How do I change into a list, convert to integers, and have the number on each line?
<h1>Writes numbers from 0 to 10 into a CSV file</h1>

<p>import csv</p>

<pre><code>fileW = open('numbers.csv', 'w')
fileW.write('0,')
fileW.write('\n1,')
fileW.write('\n2,')
fileW.write('\n3,')
fileW.write('\n4,')
fileW.write('\n5')
fileW.write('\n6,')
fileW.write('\n7,')
fileW.write('\n8,')
fileW.write('\n9,')
fileW.write('\n10')
fileW.close();
</code></pre>

<h1>Read the numbers into a list</h1>

<pre><code>fileR = open('numbers.csv')
contnts = fileR.read()
print(contents)
</code></pre>

<p>This is my code. How do I convert this into integers and change into a list so that when I print the contents I got one column of numbers: one number on each line like [0 on first line, 1 on second line, 2 on third line...]?</p>

<p>This is a pythonic way to save, obtain the numbers and create a list named int_list with all those integers:</p>

<pre><code>with open('numbers.csv', 'w') as fileW:
    for i in range(11):
        fileW.write('%s\n'%i)

int_list = []
with open('numbers.csv','r') as fileR:
    for line in fileR:
        line = line.rstrip('\n') # read line and clean the EOL
        int_list.append(int(line))
        print(line) 

print(int_list)
</code></pre>

<p>Output:</p>

<blockquote>
  <p>0 <br>1<br> 2<br> 3<br> 4<br> 5<br> 6<br> 7<br> 8<br> 9<br> 10<br> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<br></p>
</blockquote>

<p>Now you can operate the list.</p>

python