Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- no_of_guesses = 0
- correct_guesses = 0
- while True :
- correct_num = randint(1,9)
- guessed_option = input("Guess a number between 1 and 9 : ")
- if guessed_option == "exit" :
- print("Total no of guesses = %d"%(no_of_guesses))
- print("Total no of correct guesses =%d"%(correct_guesses))
- break
- else :
- if int(guessed_option) == correct_num :
- print ("exactly right")
- no_of_guesses +=1
- correct_guesses +=1
- elif int(guessed_option ) < correct_num :
- print("too less")
- no_of_guesses +=1
- elif int(guessed_option) > correct_num :
- print("too much")
- no_of_guesses +=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement