Created
February 11, 2024 17:01
-
-
Save mustafaaloko/ffe0e6ed76c49eaac0a353f649ae0483 to your computer and use it in GitHub Desktop.
Python Number Guess Game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random_number = random.randint(1, 20) | |
chance = 5 | |
for i in range(1, 6): | |
guess_number = int(input("Take a guess (" + str(chance) + " chances): ")) | |
if guess_number == random_number: | |
print("You Won!") | |
exit() | |
if guess_number < random_number: | |
print("You guessed too low") | |
chance = chance - 1 | |
if guess_number > random_number: | |
print("You guessed too high") | |
print("You Lost!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment