diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36588e9f3..103b14c30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,3 +7,5 @@ Please ensure your pull request adheres to the following guidelines: - Make sure your text editor is set to remove trailing whitespace. Thank you for your suggestions! + +3. Luke HONG! https://github.com/settings/profile diff --git a/Python/Luke_Hong_game.py b/Python/Luke_Hong_game.py new file mode 100644 index 000000000..91433d574 --- /dev/null +++ b/Python/Luke_Hong_game.py @@ -0,0 +1,33 @@ +import random + +print("Welcome to the Number Guessing Game!") +print("I'm thinking of a number between 1 and 100.") + +# generate a random number +secret_number = random.randint(1, 100) + +# keep track of attempts +attempts = 0 + +while True: + guess = input("Take a guess (or type 'quit' to stop): ") + + if guess.lower() == "quit": + print("Goodbye!") + break + + if not guess.isdigit(): + print("Please enter a number!") + continue + + guess = int(guess) + attempts += 1 + + if guess < secret_number: + print("Too low! Try again.") + elif guess > secret_number: + print("Too high! Try again.") + else: + print(f"🎉 You got it! The number was {secret_number}.") + print(f"It took you {attempts} tries.") + break