Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Guess #55

Open
Nelson19so opened this issue May 14, 2024 · 2 comments
Open

Guess #55

Nelson19so opened this issue May 14, 2024 · 2 comments

Comments

@Nelson19so
Copy link

No description provided.

@Nelson19so
Copy link
Author

import random

def display_menu():
print("Welcome to Guessing Game Puzzle")
print("1. Select Level")
print("2. Exit")

def game_level():
print("Choose your game level")
print("3. Easy")
print("4. Hard")

def play_game(chances):
number = random.randint(1, 100)
print("Guess the number: ")
while chances > 0:
guess_number = int(input())
if guess_number < number:
print("Number too low")
elif guess_number > number:
print("Number too high")
elif guess_number == number:
print("You win!")
break
print("Number of chances left: ", chances)
chances -= 1
if chances == 0:
print("You lose!")

def main():
display_menu()
choice = int(input("Enter your preference: "))
if choice == 1:
game_level()
level = int(input("Enter your preferred level: "))
if level == 3:
play_game(10)
elif level == 4:
play_game(5)
else:
print("Wrong input")
elif choice == 2:
print('Exiting game')
else:
print("Try again")

if name == "main":
main()

@Nelson19so
Copy link
Author

Nice

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant