Last active
February 7, 2017 20:29
-
-
Save shamikalashawn/a452e0eed20677f55b71093d9c50bbfe to your computer and use it in GitHub Desktop.
Guess a number between 0 and 100. You'll get clues as to whether your guess is "higher" or "lower" than the actual answer.
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
from random import randint | |
print ('---------------------------------------------' + '\n' + ' GUESS THE NUMBER APP' + '\n' + '---------------------------------------------' + '\n') | |
number = randint(1, 100) | |
while True: | |
guess = input('Guess a number between 0 and 100 ("quit" to stop): ') | |
if not guess.isdigit(): | |
print("That's not a good guess! Please type a number.") | |
elif int(guess) < number: | |
print('Sorry but {} is LOWER than the number'.format(guess)) | |
elif int(guess) > number: | |
print('Sorry but {} is HIGHER than the number'.format(guess)) | |
elif int(guess) == number: | |
print("YES! You've got it. The number was {}.".format(number)) | |
play_again = input('Would you like to play again? Yes or No?: ') | |
if play_again.lower() == 'yes': | |
number = randint(1, 100) | |
elif play_again.lower() == 'no': | |
print('Well, hope you had fun! Thanks for playing. ^_^') | |
break | |
elif guess.lower() == 'quit': | |
print('Well, hope you had fun! Thanks for playing. ^_^') | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment