Tom_Jung

Untitled

Jan 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import random
  2. number = random.randint(1,100)
  3. print(number)
  4.  
  5. def guess_game():
  6. print ("Guess a number game: make a guess between 1 and 100: ")
  7. guess = int(input("Enter your guess: "))
  8. count = 0
  9. while guess != number:
  10.  
  11. count = count + 1
  12.  
  13. if guess > number:
  14. print ('your guess is too high. Try again.')
  15.  
  16. elif guess < number:
  17. print ('your guess is too low. Try again.')
  18.  
  19. else:
  20. print("Bingo, that is it.")
  21.  
  22.  
  23. guess = int(input("Guess again: "))
  24.  
  25. print("Good job, you got it!")
  26. print("Guesses taken: ", count)
  27.  
  28. guess_game()
Advertisement
Add Comment
Please, Sign In to add comment