View Single Post
Old Jan 24th, 2008, 2:07 PM   #38
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Re: My pyguessinggame

You still have code indented incorrectly...

   if __name__ == '__main__':
      start()
      print
      raw_input('press return')
   else:
      print 'Module guessgame imported'
      print 'to run, type:guessgame.start()'
      print 'to refresh, type:reload (guessgame)'

Should be indented like so:

#guessgame********** (1/20/08)
from random import randint
def start():
   answer=randint(1,101) #the answer
   guessnum=0 #number of user guesses
   guess=input('''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=input ('''guess again please, within the limit this time''')
      elif guess == 0:
         print 'actually zero is not within the 1-100 range'
         guess=input('guess again please')
      elif guess < 0:
         print 'are you testing me?'
         guess=input('guess again, in the positives please')
      elif guess > 0 and guess < 100 and guess < answer:
         print 'that guess is below the answer'
         guess=input('try guessing again')
      elif guess >0 and guess < 100 and guess > answer:
         print 'guess lower, your answer is to high'
         guess=input('try once more')
   if guess == answer:
      print 'congratualtions, that took', guessnum, 'tries'
if __name__ == '__main__':
   start()
   print
   raw_input('press return')
else:
   print 'Module guessgame imported'
   print 'to run, type:guessgame.start()'
   print 'to refresh, type:reload (guessgame)'
#end game

raw_input('press enter to quit')

And what in the world are you talking about with "remotely opening the file"?

Again... just use IDLE and run it from there. As simple as that...
Sane is offline   Reply With Quote