[Tutor] Random in loop

ryan luna ryan_gm at sbcglobal.net
Sun Jan 15 03:12:41 CET 2006


Thank you alot ^^ so simple and i knew it, but last
time i tried 
it i got an error on the =, most have been making a
stupid mistake
--- "ZIYAD A. M. AL-BATLY" <zamb at saudi.net.sa> wrote:

> On Sat, 2006-01-14 at 17:52 -0800, ryan luna wrote:
> > Hello, Im kinda stuck on something in the book
> Python
> > Programming.
> > The "Challenage" is to make a progam that flips a
> coin
> > 100 times and then tells you the number of heads
> and
> > tails.
> > here is what i have so far,
> > Code:
> > 
> > import random
> > 
> > coin = 0
> > heads = 0
> > tails = 0
> > 
> > heads_tails = random.randrange(2)
> Why is the above line outside the loop?  Shouldn't
> you be flipping it a
> 100 times?  You're doing it once in this program. 
> (I think you know by
> know what you should do to correct this!)
> 
> > while coin < 100:
> >     coin += 1
>  <snip>
> 
> 
> I hope this was helpful.
> Ziyad.
> 
> 



More information about the Tutor mailing list