├── Example Code └── README.md /Example Code: -------------------------------------------------------------------------------- 1 | # Example of a simple text-based game "Guess the Number" 2 | import random 3 | 4 | def guess_number_game(): 5 | number_to_guess = random.randint(1, 100) 6 | attempts = 0 7 | while True: 8 | guess = int(input("Guess the number between 1 and 100: ")) 9 | attempts += 1 10 | if guess < number_to_guess: 11 | print("The number is higher") 12 | elif guess > number_to_guess: 13 | print("The number is lower") 14 | else: 15 | print(f"Congratulations! You guessed the number {number_to_guess} in {attempts} attempts.") 16 | break 17 | 18 | # Start the game 19 | guess_number_game() 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Text-based-Game-in-Python 2 | This repository features a simple text-based game "Guess the Number" implemented in Python 3 | --------------------------------------------------------------------------------