Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; '2004': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'restart': 0.09; 'subject:How': 0.10; 'clear.': 0.16; 'finney': 0.16; 'give.': 0.16; 'guess.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'semantics': 0.16; 'statement.': 0.16; 'subject:question.': 0.16; 'subject:start': 0.16; 'code.': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'tried': 0.27; 'correct': 0.29; 'code': 0.31; 'writes:': 0.31; 'says': 0.33; 'url:python': 0.33; 'guess': 0.33; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'are,': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'expected': 0.38; 'ben': 0.38; 'to:addr:python- list': 0.38; 'rather': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'free': 0.61; 'url:3': 0.61; 'skip:* 10': 0.61; 'further': 0.61; "you've": 0.63; 'here': 0.66; '8bit%:21': 0.69; 'received:125': 0.84; 'subject:. ': 0.84; 'subject:Very': 0.84; 'url:reference': 0.84; 'faith': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Very basic question. How do I start again? Date: Fri, 22 Aug 2014 11:55:58 +1000 References: <1e5dv9l3aik5bb1jn4vil731rdl7q6sl3l@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:R+DQljO5YnjUv5C/nq/vXYiEnOg= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408672574 news.xs4all.nl 2845 [2001:888:2000:d::a6]:43671 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76764 Seymore4Head writes: > The program works as expected until the computer gets a correct guess. > I don't know what I should be doing to restart the program when > pick=guess. There isn't a “restart the program” code we can give. But I think you need only something rather simpler: > while count < 100: > guess = random.randrange(low,high) > print (pick, guess) > if guess == pick: > print ("correct") > > #"What I need is something here that says start over" You can end the current loop with the ‘break’ statement. See the docs to see exactly what its semantics are, and try using that in your code. Feel free to ask further questions when you've tried that, if it's still not clear. -- \ “Religious faith is the one species of human ignorance that | `\ will not admit of even the *possibility* of correction.” —Sam | _o__) Harris, _The End of Faith_, 2004 | Ben Finney