<div><br>You can use, '\n' with each value, that u are writing to the file.</div>
<div>&nbsp;</div>
<div>eg.&nbsp;&nbsp; outstring = outstring + '\n'</div>
<div>&nbsp;</div>
<div>\n&nbsp; stands for new line character.</div>
<div>&nbsp;</div>
<div>I couldnt get the second question.</div>
<div>&nbsp;</div>
<div>Regarding the third question, you can do this:</div>
<div>&nbsp;</div>
<div>done = 0</div>
<div>fd = open(filename,'r')</div>
<div>while not done:</div>
<div>&nbsp;&nbsp;&nbsp; line = fd.readline()</div>
<div>&nbsp;&nbsp;&nbsp; if line == '':</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; done = 1</div>
<div>&nbsp;&nbsp;&nbsp; else:</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i in line:</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dict[i] = int(dict[i]) + 1&nbsp;&nbsp;&nbsp; # dict is a dictionary containing numbers as the keys and initial value 0 for each key<br>&nbsp;</div>
<div>&nbsp;</div>
<div>HTH,</div>
<div>&nbsp;</div>
<div>Regards,</div>
<div>Asrarahmed Kadri</div>
<div>&nbsp;</div>
<div><span class="gmail_quote">On 11/26/06, <b class="gmail_sendername">Moedeloos Overste</b> &lt;<a href="mailto:kloosterjunkie@hotmail.com">kloosterjunkie@hotmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi everybody,<br><br>I am new to python and trying to write a lottery program for a<br>schoolproject.<br><br>
The program is supposed to draw the lottery any entered(user input) number<br>of times, then store the drawing results in a file. After drawings the user<br>should see (if he wants to) how many times each of the possible numbers was
<br>picked by the computer and which were the six most succesful numbers. These<br>data must be calculated from the data stored in the file!<br><br>This is what I've been able to come up with so far:<br><br># Lottery chances.
<br># Programs ask how many times you want to have the lottery drawn by the<br># computer. Then stores these draws and then shows the 6 numbers most drawn<br># by the computer.<br><br># Importing for making the program nicer later on...
<br>import os, sys<br>import time<br>import random<br><br><br>vDraws = input(&quot;How many times do you want to draw the lottery? :&gt;&quot;)<br><br># Draw lottery numbers &amp; writing them to file<br><br>while vDraws &gt; 0:
<br>&nbsp;&nbsp; List_LotNumbers = random.sample(range(0,46), 6) #random numbers from<br>range into list<br>&nbsp;&nbsp; output_string = str(List_LotNumbers) #converting list to string to store<br>it.<br>&nbsp;&nbsp; fout = open(&quot;draw__output.dat&quot;, &quot;a&quot;)
<br>&nbsp;&nbsp; fout.write(output_string)&nbsp;&nbsp; #writing string to file<br>&nbsp;&nbsp; fout.close()<br>&nbsp;&nbsp; vDraws = vDraws - 1<br><br><br># Printing all numbers drawn<br><br>vView = raw_input(&quot;Do want to see the results? y/n :&gt;&quot;)<br>
<br>if vView == &quot;y&quot; or vView == &quot;Y&quot;:<br>&nbsp;&nbsp; fout = open(&quot;draw__output.dat&quot;, &quot;r&quot;)<br>&nbsp;&nbsp; Print_list = fout.readline()<br>&nbsp;&nbsp; print Print_list<br><br>#end of program so far<br><br>My question is: how do I write the output of each lottery drawing on a
<br>separate line<br><br>second question: how do i print the lottery drawings to the screen without<br>the brackets[]<br><br>third:can somebody point me in the right direction as to how do I make the<br>program read from the file and count how many times a number has been drawn.
<br><br>Any help or pointers would greatly be appreciated.<br><br>thanks,<br><br>Robert (forgive me my english, I am Dutch)<br><br>_________________________________________________________________<br>Windows Live Mail: Kies je eigen kleur, indeling en contacten!
<br><a href="http://imagine-windowslive.com/mail/launch/default.aspx?Locale=nl-nl">http://imagine-windowslive.com/mail/launch/default.aspx?Locale=nl-nl</a><br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;
<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br><br clear="all"><br>-- <br>To HIM you shall return.