Hello! I am a newbe to python and apologize in advance for this question, because I am sure it is an easy fix that I am oblivious too -
I wrote this simple program for a guessing game- very basic, which is fine - but when you get to the end of the game, and guess the correct number, the number of tries is off by ONE - it is driving me mad! here is what the code consists of (runs fine aside from that flaw)
count = 0
secret = random.randint (1, 100)
print ("Guessing game - Guess my secret number - number between 1-100")
guess = int(input("Your Guess?"))
while (guess != secret):
if (guess > secret):
print ("Your guess is higher")
guess = int(input("Guess again:"))
elif (guess < secret):
print ("Your guess is lower")
guess = int(input("Guess again:"))
else:
print ("You Guessed it!It took you", count, "tries.")