Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. from random import randint
  2. no_of_guesses = 0
  3. correct_guesses = 0
  4. while True :
  5. correct_num = randint(1,9)
  6. guessed_option = input("Guess a number between 1 and 9 : ")
  7.  
  8. if guessed_option == "exit" :
  9. print("Total no of guesses = %d"%(no_of_guesses))
  10. print("Total no of correct guesses =%d"%(correct_guesses))
  11. break
  12. else :
  13. if int(guessed_option) == correct_num :
  14. print ("exactly right")
  15. no_of_guesses +=1
  16. correct_guesses +=1
  17. elif int(guessed_option ) < correct_num :
  18. print("too less")
  19. no_of_guesses +=1
  20. elif int(guessed_option) > correct_num :
  21. print("too much")
  22. no_of_guesses +=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement