Posted By

louscomp on 12/17/09


Tagged

number python random console guess


Versions (?)

Guess the number


 / Published in: Python
 

  1. import sys
  2. import random
  3.  
  4. salir = ""
  5. numero = random.randrange(1,10,1)
  6. print "Guess the number I'm thinking of 1 to 10"
  7. while salir != "q":
  8. respuesta = input("Enter the number you think I'm thinking between 1 and 10\n")
  9. if respuesta == numero:
  10. print "That's it"
  11. raw_input()
  12. sys.exit()
  13. elif respuesta < numero:
  14. print "The number is greater than this try again"
  15. elif respuesta > numero:
  16. print "The number is small than this try again"
  17. else:
  18. print "You have not written anything."
  19. salir = raw_input("Press q to exit and enter to try again")

Report this snippet  

You need to login to post a comment.