[Tutor] Challenge

Ali Sina seena_blk at yahoo.com
Tue Sep 22 14:13:32 CEST 2009


Hello tutor

I downloaded a guide about learning Python by Michael Dawson which has challenges at the end of each chapter. I'm a novice so I encountered a problem with this challenge:

"Write a program that flips a coin 100 times and then tells 
you the number of heads and tails."
I wrote this code but I know its wrong. Although it works properly:

flips=0
h='heads'
t='tails'
while True:
    flips+=1
    if flips>100:
        break
    if True:
        print(flips,'=',h or t)

But it prints every number with the string 'heads'. I'm really blank at this. It may have something to do with the 'random' module.

Regards




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090922/2f066121/attachment.htm>


More information about the Tutor mailing list