What's wrong with this code?

Nathan Pinno falcon3166 at hotmail.com
Sat Jul 2 13:43:46 EDT 2005


  Hi all,

  What's wrong with the following code? It says there is name error, that
random is not defined. How do I fix it?

  # Plays the guessing game higher or lower.
  # Originally written by Josh Cogliati, improved first by Quique, then by
Nathan Pinno.
  print "Higher or Lower"
  print
  number = random.choice(range(100))
  guess = 0
  while guess != number:
      guess = input("Guess a number: ")
      if guess > number:
          print "Too high"
          guess = input("Guess a number: ")
      elif guess < number:
          print "Too low"
          guess = input("Guess a number: ")
  print "Just right"

  Thanks.
  Nathan Pinno
  http://www.npinnowebsite.ca/



-- 


----------------------------------------------------------------
     Posted via UsenetRevolution.com - Revolutionary Usenet
** HIGH RETENTION ** Specializing in Large Binaries Downloads **
                 http://www.UsenetRevolution.com



More information about the Python-list mailing list