Answers for "how to count the number of guesses in python"

0

how to count the number of guesses in python

from random import randint
guesses = 0
randomNum = (randint(0,100))
numPlayer = 0
while (numPlayer!=randomNum):
    numPlayer = int(input("Guess the number(0-100)"))
    if (numPlayer>randomNum) : 
        print "It's -"  
    elif (numPlayer<randomNum) : print("It's +")
    guesses=guesses+1

print ("Well done you guessed my number in %d guesses" % guesses)
Posted by: Guest on June-25-2020

Code answers related to "how to count the number of guesses in python"

Python Answers by Framework

Browse Popular Code Answers by Language