How to write a while loop into a CSV file : <p>My code looks like:</p>

<pre><code>x=0
while (x&lt;3):
    print('purple'),
    print('yellow'),
    print({x})
    x=x+1
</code></pre>

<p>I want it to log this data into a csv file named 'daffodils.csv'.
How do I do this so that the iterations won't write over eachother?</p>

<p>For example, if I ran the program two times, my csv file will look like:</p>

<pre><code>purple yellow 0
purple yellow 1
purple yellow 2
purple yellow 0
purple yellow 1
purple yellow 2
</code></pre>

<p>Thanks</p>
