Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subject:error': 0.03; 'tries': 0.07; 'lines.': 0.09; 'spaces': 0.09; 'subject:while': 0.09; 'cc:addr:python-list': 0.11; 'random': 0.14; '"guess': 0.16; "'if',": 0.16; 'gpg': 0.16; 'loops': 0.16; 'script?': 0.16; 'subject:program': 0.16; 'you"': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'there.': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'guess': 0.33; 'received:google.com': 0.35; 'that!': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'so,': 0.37; 'project': 0.37; 'pm,': 0.38; 'url:mail': 0.40; 'lower': 0.61; 'full': 0.61; 'took': 0.61; 'from:charset:utf-8': 0.61; 'real': 0.63; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'press': 0.70; 'eight': 0.74; 'secret': 0.74; 'subject:First': 0.74; '100': 0.79; 'guessed': 0.84; 'number):': 0.84; 'url:tk': 0.95; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=xC6zIqMdPq0GwY8wmW1Ltq4jyl/alWz0VMjtfrnkwgU=; b=kfkS6Kl+76DDVO/NiQCE3yKRJMAFyPd7ZAxAmQcDzpYdrd1OD1t/T9lMO5on5nlYUa kvHtzPncCfbHF5IMGZ6/8TF4ypkcaLomsxKlTBP7pBYHf+hTbrZ5xNFkSc8koY+edtjv 73ldsCBl4eyj+8UbHO4xNIso8h6lEyF83htLfbvsBMRz2p1PUUstBZB+7VCp94aVON0M d13U9kMqpm0Fy2z6YCM5djebtvYJ3a+lc64HHjkYL7NYGWBrznBEF/WSffvhRoCr2nQb CNlJMyvZaWCXvLHbviGcqL0yW3yWVc9KuAF3DgJgALjKap0TKu6weA7H3emFNkog7pl0 iPjg== X-Received: by 10.50.108.70 with SMTP id hi6mr258700igb.21.1367602027056; Fri, 03 May 2013 10:27:07 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <24c5856e-a30a-41bd-aa4a-0e594734e1f8@googlegroups.com> References: <24c5856e-a30a-41bd-aa4a-0e594734e1f8@googlegroups.com> From: =?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= Date: Fri, 3 May 2013 19:26:46 +0200 Subject: Re: First python program, syntax error in while loop To: ryankoch38@gmail.com Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367602030 news.xs4all.nl 15884 [2001:888:2000:d::a6]:54821 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44673 On Fri, May 3, 2013 at 7:18 PM, wrote: > title = "Guess my number game:" > print title.title() > raw_input("Press any key to continue..") > > import random > > tries = 0 > number = random.randrange(99) + 1 > guess = int(raw_input("Guess my number! Secret - It is between 1 and 100 :") > > while (guess != number): > if (guess > number): > number = int(raw_input("Sorry, my number is lower than that! \n Try again:") > tries += 1 > else if (guess < number): > number = int(raw_input("Sorry, my number is higher than that! \n Try again:") > tries += 1 > print "Congratulations, you guessed my number! \n And it only took you" tries "tries!" > > raw_input("\n\n Press any key to exit..") > > ## what is wrong with this script? I'm just trying to understand while loops and ## this is not a real project :P > -- > http://mail.python.org/mailman/listinfo/python-list 1. post full tracebacks. 2. The contents of your while loop must be indented, just like the contents of the if/else if statement you have there. So, four spaces before the 'if', 'else if' and 'print' lines; eight before 'number' and 'tries' lines. -- Kwpolska | GPG KEY: 5EAAEA16 stop html mail | always bottom-post http://asciiribbon.org | http://caliburn.nl/topposting.html