anyone tell me why my program will not run?

Pavel Volkov sailor at lists.xtsubasa.org
Sat Nov 21 12:15:05 EST 2015


On суббота, 21 ноября 2015 г. 6:30:02 MSK, Dylan Riley wrote:

Also some more notes:

> heads = int("1")
> tails = int("2")

Why use this strange initialization? The usual way:
heads = 1
tails = 2
gives the same result.

> while flips != 0:
>     flips -= 1

There's no need to use while and flips variable:

for _ in range(100):
    if random.randint(heads, tails) == heads:
        headscount += 1
    else:
        tailscount += 1
  
Also, it's good to put import at the beginning.



More information about the Python-list mailing list