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>let's use a for loop, shall we ?</p>

<pre><code># generate the list with commas
fileW = open('numbers.csv', 'w')
for i in xrange(11):
    fileW.write('%s,\n'%i)
fileW.close()


# open the file and read line by line    
with open('numbers.csv','r') as fileR:
    for line in fileR:
       # remove the trailing comma, and convert back to integer 
       print int(line[:-1]) +100
</code></pre>

python