Thank you for posting your code. That really helps us see where you are and therefore how to help.

I encourage you to "desk check" your code: pretend you are the computer: write down the values of variables and expressions as things change. Evaluate each statement to see what it does.

Example:

heads    tails    flip    flip < 100     while flip < 100:
0            1       100    False         loop not entered
program ends.

I hope you understand why the loop is not entered. If not please (re)read an explanation of while.

Noticing that you would alter the loop condition. To do that you need to ask "When do I want the loop to end?"

Let's say you changed it to: while flip <= 100. Now your "desk check" would look like:

heads    tails    flip    flip <= 100     while flip <= 100:
0            1       100    True             loop entered
                        99    
random.randrange(2)
has no effect since nothing is done with the value returned
flip < 100   break
True         leaves the loop

print "\nThe amount of times tails came up was" , tails , "The amount of times heads came up was" , heads
results in: The amount of times tails came up was 1 The amount of times heads came up was 0

I hope this helps.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to