Advertisement
misingnoglic

Untitled

Feb 21st, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. print("Please think of a number between 0 and 100!")
  2. high=100
  3. low=0
  4. correct=False
  5. while correct==False:
  6. average= ((high+low))/2
  7. print("Is your secret number "+str(average)+"?")
  8. valid=True
  9. while valid:
  10. guess=str(raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. "))
  11. if guess=="h":
  12. high=average
  13. if guess=="l":
  14. low=average
  15. if guess=="c":
  16. print ("Game over. Your secret number was: "+str(average))
  17. correct = True
  18. else:
  19. print("Sorry, I did not understand your input.")
  20. valid=False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement