Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: anyone tell me why my program will not run? Date: Sun, 22 Nov 2015 16:39:08 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 31 Message-ID: References: <1737402a-2f4d-440a-abd7-6cc500f673e1@googlegroups.com> NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1448210348 5132 166.84.1.1 (22 Nov 2015 16:39:08 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Sun, 22 Nov 2015 16:39:08 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:99240 In <1737402a-2f4d-440a-abd7-6cc500f673e1@googlegroups.com> Dylan Riley 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@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"