Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44673
| References | <24c5856e-a30a-41bd-aa4a-0e594734e1f8@googlegroups.com> |
|---|---|
| From | Chris “Kwpolska” Warrick <kwpolska@gmail.com> |
| Date | 2013-05-03 19:26 +0200 |
| Subject | Re: First python program, syntax error in while loop |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1272.1367602030.3114.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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