how to count the number of guesses in python code example
Example: 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)