Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant