# -*- coding: utf-8 -*-
"""Medium Project (1st)-Khalid AlHarbi

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1_2IOIia0OdKe7kAmkr21AjHUXdLd6cAP
"""

import random

def number_guessing_game():
    print("Welcome to the Number Guessing Game!")
    print("I'm thinking of a number between 1 and 100. Can you guess it?")

    number_to_guess = random.randint(1, 100)
    attempts = 0
    max_attempts = 10

    while attempts < max_attempts:
        guess = int(input("Enter your guess: "))

        if guess < number_to_guess:
            print("Too low! Try again.")
        elif guess > number_to_guess:
            print("Too high! Try again.")
        else:
            print("Congratulations! You guessed the number correctly in", attempts + 1, "attempts.")
            return

        attempts += 1
        attempts_left = max_attempts - attempts
        print("Attempts left:", attempts_left)

    print("Sorry, you've run out of attempts. The number I was thinking of was:", number_to_guess)

while True:
    number_guessing_game()
    play_again = input("Do you want to play again? (yes/no): ")
    if play_again.lower() != 'yes':
        print("Thanks for playing! Goodbye!")
        break