Guest User

Untitled

a guest
Oct 17th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import random
  2.  
  3. rng = random.randint(1, 9)
  4. c= 0
  5. while True:
  6.  
  7. inp = int(input("take a guess between 1 to 9""\n" "or type exit if you are bored: ""\n"))
  8. c += 1
  9.  
  10. if str(inp) == "exit":
  11. break
  12. elif inp >= 10 or inp <= 0:
  13. print ("your number It is out of range wrong guess")
  14. elif inp > rng:
  15. print ("try a lower number your number was: {}".format(inp))
  16. elif inp < rng:
  17. print ("try a higher number your number was: {}".format(inp))
  18. elif inp == rng:
  19. print ("It took you {} guesses to find the number :D".format(c))
  20. break
Add Comment
Please, Sign In to add comment