[Tutor] Whle Loop to run again.

. , administrata at hotmail.com
Thu May 19 16:50:16 CEST 2005


Hi,

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

thanks.

-------------------------------------------------------------------------------------------------------------------------------------------
import random

raw_input("Flip a coin!")

head = 0
tail = 0
run = ""

while (head + tail) < 100:
    coin = random.randrange(2)
    if coin == 0:
        head += 1

    elif coin == 1:
        tail += 1

    elif run == "run":
        continue

    elif run == "ex1t":
        print ex1t
        break

    else:
        print "Error"

print "\n", head, "heads,", tail, "tails out of 100."




run = raw_input("\n'run' again or 'exit' ")

ex1t = raw_input("\nPress the enter key to exit.")
-------------------------------------------------------------------------------------------------------------------------------------------

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



More information about the Tutor mailing list