SHARE
TWEET

Untitled

a guest Feb 9th, 2012 56 Never
  1. #guessing game, user picks #, computer guesses
  2. guess = 50
  3. low = 1
  4. high = 100
  5. answer = ""
  6. while answer != "y":
  7.     answer = raw_input("Is your number %s? (Yes,Higher,Lower)" % guess)
  8.     if answer == "h":
  9.         low = guess
  10.         guess = (guess + high)/2
  11.     if answer == "l":
  12.         high = guess
  13.         guess = (guess + low)/2
  14.     if answer == "y":
  15.         print "i won!"
RAW Paste Data
Top