Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'that?': 0.05; 'failing': 0.07; 'tries': 0.07; '22,': 0.09; 'check,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'random': 0.14; 'assignment.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guess.': 0.16; 'infinitely': 0.16; 'looping': 0.16; 'loops': 0.16; 'subject:question.': 0.16; 'subject:start': 0.16; 'traceback.': 0.16; 'exception': 0.16; 'wrote:': 0.18; '(not': 0.18; 'code,': 0.22; '(in': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'right.': 0.26; 'asking': 0.27; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'am,': 0.29; "doesn't": 0.30; 'direction': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'program,': 0.31; 'go.': 0.31; 'helpful.': 0.31; 'terminate': 0.31; 'computer.': 0.33; 'fri,': 0.33; 'guess': 0.33; 'problem': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; "i'll": 0.36; 'subject:?': 0.36; 'should': 0.36; 'wrong': 0.37; 'so,': 0.37; 'being': 0.38; 'expect': 0.39; 'does': 0.39; 'extremely': 0.39; 'though,': 0.39; 'how': 0.40; 'most': 0.60; 'tell': 0.60; 'full': 0.61; 'entire': 0.61; 'simply': 0.61; "you're": 0.61; 'here:': 0.62; 'more': 0.64; 'subject:. ': 0.67; 'between': 0.67; 'answer.': 0.68; 'honest': 0.78; '100': 0.79; 'fail.': 0.84; 'homework': 0.84; 'pasting': 0.84; 'subject:Very': 0.84; 'to:none': 0.92; 'incredibly': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=eH5VZLJ6OEz/Jml48OZFozDRL8j9X8tMadhuwufZxi4=; b=p++EroKX9NgPOHmh9G/aQ5S3bVv0/CpaCUjwwKiBugB8nCJoFo2h/kdUe1ptyvQIgq 21E/iHJ6sKWSdgdKb0Yr7+AmwNrjdiNYbH+Ty+bzs1TidBpEQG86oeJLM3IhnDL4/Mc8 aCvG7Zrg7c6QlcMX9/8DzUNPrfQfGuixcKEUrR1lHU+umbFOdx+dW9Ga6InvdKcgiQBF du02Lo/m2M67YZtWsv9uWkQo6QS0vIjlAPKYMIaxvv+GyYzD2N2XSeS9ddDokJBm0Cu9 ZptFoxWhhOKmaCuzM+J25RyixJhObsI2rZ5JVsESYZ175ESVZuOg5MgY1BvNwUmqLDie F0/w== MIME-Version: 1.0 X-Received: by 10.51.17.2 with SMTP id ga2mr8432141igd.2.1408672680328; Thu, 21 Aug 2014 18:58:00 -0700 (PDT) In-Reply-To: <1e5dv9l3aik5bb1jn4vil731rdl7q6sl3l@4ax.com> References: <1e5dv9l3aik5bb1jn4vil731rdl7q6sl3l@4ax.com> Date: Fri, 22 Aug 2014 11:58:00 +1000 Subject: Re: Very basic question. How do I start again? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 1408672684 news.xs4all.nl 2872 [2001:888:2000:d::a6]:45809 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76765 On Fri, Aug 22, 2014 at 11:37 AM, Seymore4Head wrote: > I want to give the computer 100 tries to guess a random number between > 1 and 100 picked by the computer. > Suggestion: Be up-front about this being a homework assignment. Most of us can tell anyway, and it's more honest that way :) So, since this is homework, I'm not going to give you the answer. What I'll do is point you in the direction you need to go. The most important problem isn't in your code, it's actually here: > The program fails when guess=pick In Python, a program doesn't simply fail. It might do the wrong thing (in which case you should tell us both what it does and what you expect it to do), or it might terminate with an exception traceback. Those tracebacks are incredibly useful; when you're asking for help with a failing program, pasting the entire traceback, including the full error message, is extremely helpful. In this case, though, what I'm seeing is that the program will errantly keep looping when it gets it right. (Not infinitely as you have the "count < 100" check, but it still loops more than it should.) So what you need to do is tell it to stop looping when it gets the right guess. Do you know how to do that? ChrisA