Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44673

Re: First python program, syntax error in while loop

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 <kwpolska@gmail.com>
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 Chris “Kwpolska” Warrick <kwpolska@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1272.1367602030.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Fri, May 3, 2013 at 7:18 PM,  <ryankoch38@gmail.com> 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 <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail                | always bottom-post
http://asciiribbon.org        | http://caliburn.nl/topposting.html

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

First python program, syntax error in while loop ryankoch38@gmail.com - 2013-05-03 10:18 -0700
  Re: First python program, syntax error in while loop John Gordon <gordon@panix.com> - 2013-05-03 17:27 +0000
  Re: First python program, syntax error in while loop Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-05-03 19:26 +0200
    Re: First python program, syntax error in while loop John Gordon <gordon@panix.com> - 2013-05-03 17:37 +0000
  Re: First python program, syntax error in while loop MRAB <python@mrabarnett.plus.com> - 2013-05-03 18:36 +0100
  Re: First python program, syntax error in while loop Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-05-03 12:37 -0500
  Re: First python program, syntax error in while loop ryankoch38@gmail.com - 2013-05-03 10:57 -0700
    Re: First python program, syntax error in while loop John Gordon <gordon@panix.com> - 2013-05-03 18:21 +0000
      Re: First python program, syntax error in while loop ryankoch38@gmail.com - 2013-05-03 11:34 -0700
  Re: First python program, syntax error in while loop ryankoch38@gmail.com - 2013-05-03 12:52 -0700
    Re: First python program, syntax error in while loop John Gordon <gordon@panix.com> - 2013-05-03 20:04 +0000
  Re: First python program, syntax error in while loop ryankoch38@gmail.com - 2013-05-03 13:15 -0700
    Re: First python program, syntax error in while loop Neil Cerutti <neilc@norwich.edu> - 2013-05-03 20:30 +0000
      Re: First python program, syntax error in while loop John Gordon <gordon@panix.com> - 2013-05-03 20:38 +0000
        Re: First python program, syntax error in while loop Neil Cerutti <neilc@norwich.edu> - 2013-05-06 12:06 +0000
          Re: First python program, syntax error in while loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-06 13:37 +0100
            Re: First python program, syntax error in while loop Neil Cerutti <neilc@norwich.edu> - 2013-05-06 13:07 +0000
            Re: First python program, syntax error in while loop Roy Smith <roy@panix.com> - 2013-05-06 09:08 -0400
              Re: First python program, syntax error in while loop rusi <rustompmody@gmail.com> - 2013-05-06 06:36 -0700
              Re: First python program, syntax error in while loop Chris Angelico <rosuav@gmail.com> - 2013-05-06 23:37 +1000
                Re: First python program, syntax error in while loop roy@panix.com (Roy Smith) - 2013-05-06 11:31 -0400
                Re: First python program, syntax error in while loop Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-06 16:11 -0400
                Re: First python program, syntax error in while loop Chris Angelico <rosuav@gmail.com> - 2013-05-07 07:50 +1000
              Re: First python program, syntax error in while loop Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-06 20:16 -0400
            Re: First python program, syntax error in while loop alex23 <wuwei23@gmail.com> - 2013-05-06 17:17 -0700
              Re: First python program, syntax error in while loop Roy Smith <roy@panix.com> - 2013-05-06 20:18 -0400
              Re: First python program, syntax error in while loop Dan Sommers <dan@tombstonezero.net> - 2013-05-07 05:03 +0000
              Re: First python program, syntax error in while loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-07 07:10 +0100
              Re: First python program, syntax error in while loop Chris Angelico <rosuav@gmail.com> - 2013-05-07 19:19 +1000

csiph-web