> I want the program to run again when i input 'run' But, It
doesn't...

You need another loop, or to ask for input inside the loop.
If you always want 100 iterations then prompt for another
hundred structure it like:

run = raw_input('run or exit? ')
while run = 'run':
   for n in range(100):
      coin = random.randrange(2)
      if coin == 1: heads += 1
      else coin == 2: tails += 1
   run = raw_input('run or exit? ')


But if you want to check after every coin toss (as your if/elif chain
code
seems to suggest) but with a maximum of 100 iterations, try it this
way:

heads,tails = 0,0
while heads+tails < 100:
     coin = random.randrange(2)
     if coin == 1: heads += 1
     else coin == 2: tails += 1

     run = raw_input('run or exit? ')
     if run = 'run': continue
     else: break

HTH,

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to