Hey Guys, anybody know why when i run the program, instead of actually giving me 10 attempts, it is letting me take 12? The program works, and i think it has something to do with the fact that programs read 0 as 1 and therefore, there would be 11 guesses + the original guess that i am giving them...
import random
print("Hello, and welcome, what is your name?")
username = input()
print("We are going to try and guess a number between 0 and 100")
print("You have ten tries until you loose.")
def guess (number_to_guess):
Number = int(input((username + ", what do you think the number is? ")))
attempts = 0
while attempts <= 10:
if Number < number_to_guess:
Number = int(input(("Too low, try again!")))
attempts = attempts + 1
if Number > number_to_guess:
Number = int(input(("Too high, try again!")))
attempts = attempts + 1
elif Number == number_to_guess:
print("Good job! You guessed the number that I was thinking!" + username) break
if Number != number_to_guess:
print("Too bad, you did not guess the correct number in 10 attempts")
print("The number that I was thinking of was" + str(answer))
answer = random.randint( 0, 100 )
calling the function and the while loop
guess (answer)