anyone tell me why my program will not run?
John Gordon
gordon at panix.com
Sun Nov 22 11:39:08 EST 2015
In <1737402a-2f4d-440a-abd7-6cc500f673e1 at googlegroups.com> Dylan Riley <dylan.riley at hotmail.com> writes:
> heads = int("1")
Why are you taking the int value of a string constant? If you know you
want the value 1, why not just use it directly?
> flips = 100
> headscount = 0
> tailscount = 0
> while flips != 0:
> flips -= 1
This loop has no other effect than to set flips to zero, so why not just
set flips to zero in the first place?
> result = random.randint(heads, tails)
> if result = heads:
> headscount += 1
> else:
> tailscount += 1
Perhaps you meant to have this piece of code indented under the while
loop above?
--
John Gordon A is for Amy, who fell down the stairs
gordon at panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list
mailing list