I'm a beginner and have no idea what I'm doing wrong. Why the last statement "elif guess == number" doesn't work when I guessed the number? Here's my code:
import random
print("Welcome to the Number Guessing Game!\nI'm thinking of a number between 1 and 100.")
user_choice = input("Choose a difficulty. Type 'easy' or 'hard': ").lower()
attempts = 0
number = random.randint(1, 100)
print(number)
end_game = False
if user_choice == "easy":
attempts = 10
elif user_choice == "hard":
attempts = 5
while not end_game:
print(f"You have {attempts} attempts remaining to guess the number.")
guess = input("Make a guess: ")
if guess != number:
attempts -= 1
if attempts == 0:
print("You've run out of guesses, you lose.")
end_game = True
elif guess == number:
print(f"You got it! The answer was {number}.")
end_game = True