Created
August 5, 2020 16:31
-
-
Save DevYam/f2ca1db5508a6839b4301154695b76f4 to your computer and use it in GitHub Desktop.
Guess The Number Game
This file contains 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
# Guess the number Game | |
key = 43 | |
count = 10 | |
print("Total guesses left = ", count) | |
while True: | |
guess = input("Enter a number to guess\n") | |
if not guess.isnumeric(): | |
print("Enter a valid number") | |
continue | |
if int(guess) < key and count > 0: | |
print("you need to enter a higher value\n") | |
count = count - 1 | |
print("Total guesses left = ", count) | |
elif int(guess) > key: | |
print("you need to enter a lower value\n") | |
count = count - 1 | |
print("Total guesses left = ", count) | |
elif int(guess) == key: | |
print("Congratulations you guessed it right\n") | |
break | |
elif count == 0: | |
print("Game Over\n") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment