I am getting started with Python, and I have tried to make a "number guessing game". You have 6 guesses between 1 and 100.
The program will tell you of you are way to high, way to lo or close.
My issue is with the end of the game. I can only get my system to deliver a single message.
So the same message appears if you win or loose the game. Please finde the entire below. I appreciate your help.
import random
guesses = 6
number = random.randint(0,100)
win = True
while guesses > 0:
guess = int(input("guess: "))
guesses -= 1
if guess == number:
win == True
guesses = 0
elif abs(guess - number) < 4:
print("You are very close..", guesses, "guesses remaining")
elif guess > number:
print("Your guess is too high!", guesses, "guesses remaining")
elif guess < number:
print("Your guess is too low!", guesses, "guesses remaining")
if win == True:
print("Sorry loser!")
else:
print("Great. You won. Big deal.")