Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: First python program, syntax error in while loop Date: Fri, 3 May 2013 17:27:05 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 35 Message-ID: References: <24c5856e-a30a-41bd-aa4a-0e594734e1f8@googlegroups.com> NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1367602025 26631 166.84.1.1 (3 May 2013 17:27:05 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 3 May 2013 17:27:05 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:44672 In <24c5856e-a30a-41bd-aa4a-0e594734e1f8@googlegroups.com> ryankoch38@gmail.com writes: > 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 You're missing a second closing parentheses on the line where the user inputs their guess. Also, you need to indent the 'if' statement underneath the while loop. -- John Gordon A is for Amy, who fell down the stairs gordon@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"