View Single Post
Old Jan 23rd, 2008, 11:11 AM   #21
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

I have debugged this far

#guessgame********** (1/20/08)
from random import randint
def start():
   answer=randint(1,101) #the answer
   guessnum=1 #number of failed user guesses
   guess=raw_imput('''I am thinking of a number that is in between 1 and 100''')#the current guess of the user
   while guess != answer:
      guessnum=guessnum+1
      if guess > 100:
         print '''that guess is way too high, the answer has to be 100 or lower''' 
         guess=raw_imput ('''guess again please, within the limit this time''')
      elif guess == 0:
         print 'actually zero is not within the 1-100 range'
         guess=raw_imput('guess again please')
      elif guess < 0:
         print 'are you testing me?'
         guess=raw_imput('guess again, in the positives please')
      elif guess > 0 and guess < 100 and guess < answer:
         print 'that guess is below the answer'
         guess=raw_imput('try guessing again')
      elif guess >0 and guess < 100 and guess > answer:
         print 'guess lower, your answer is to high'
         guess=raw_imput('try once more')
if guess == answer:
  File "<stdin>", line 22
    if guess == answer:

Syntax Error: invalid syntax

The marker points to the 'F' in 'if', I have experimented over and over with the = sign == sign and all that, I even wrote a test program, look at this.

#this is a test program
ghost=1
answer=1
if ghost==answer:
   print 'boo'
works

Wheras this doesn't
#this is a test program
try=1
  File "<stdin", line 2
try=1

SyntaxError: invalid syntax
answer=1
if try==answer:
File "<stdin>", line 1
   if try==answer:

Syntax Error: invalid syntax
   print 'boo'
  File "<stdin>", line 1
    print 'boo'

IndentationError: unexpected indent
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote