import random
number = random.randint(1, 100)
print("Welcome to the Number Guessing Game! \nI am thinking a number between 1 to 100.")
level = input("Choose a difficulty level. Type 'easy' or 'hard'.\n")
if level == "easy":
attempts = 10
elif level == "hard":
attempts = 5
print(f"You have {attempts} attempts remaining to guess the number.")
def verify_guess(guess_number):
if int(guess_number) > number:
return("Too high.")
elif int(guess_number) < number:
return("Too low.")
else:
return("You got it!")
while attempts != 0:
guess_number = input("Make a guess:\n")
result = verify_guess(guess_number)
if result != "You got it!":
print(result)
attempts -= 1
print(f"You have {attempts} attempts remaining to guess the number.")
else:
attempts = 0
print (f"You got it! The number was {number}.")
if result != "You got it!":
print("You've run out of guesses, you lose.")