<div><br>You can use, '\n' with each value, that u are writing to the file.</div>
<div> </div>
<div>eg. outstring = outstring + '\n'</div>
<div> </div>
<div>\n stands for new line character.</div>
<div> </div>
<div>I couldnt get the second question.</div>
<div> </div>
<div>Regarding the third question, you can do this:</div>
<div> </div>
<div>done = 0</div>
<div>fd = open(filename,'r')</div>
<div>while not done:</div>
<div> line = fd.readline()</div>
<div> if line == '':</div>
<div> done = 1</div>
<div> else:</div>
<div> for i in line:</div>
<div> dict[i] = int(dict[i]) + 1 # dict is a dictionary containing numbers as the keys and initial value 0 for each key<br> </div>
<div> </div>
<div>HTH,</div>
<div> </div>
<div>Regards,</div>
<div>Asrarahmed Kadri</div>
<div> </div>
<div><span class="gmail_quote">On 11/26/06, <b class="gmail_sendername">Moedeloos Overste</b> <<a href="mailto:kloosterjunkie@hotmail.com">kloosterjunkie@hotmail.com</a>> 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("How many times do you want to draw the lottery? :>")<br><br># Draw lottery numbers & writing them to file<br><br>while vDraws > 0:
<br> List_LotNumbers = random.sample(range(0,46), 6) #random numbers from<br>range into list<br> output_string = str(List_LotNumbers) #converting list to string to store<br>it.<br> fout = open("draw__output.dat", "a")
<br> fout.write(output_string) #writing string to file<br> fout.close()<br> vDraws = vDraws - 1<br><br><br># Printing all numbers drawn<br><br>vView = raw_input("Do want to see the results? y/n :>")<br>
<br>if vView == "y" or vView == "Y":<br> fout = open("draw__output.dat", "r")<br> Print_list = fout.readline()<br> 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 -
<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.