Created
February 7, 2019 22:01
-
-
Save pdbartsch/239ecd796a3bbf4762c7a409e4285f15 to your computer and use it in GitHub Desktop.
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 | |
num = random.randrange(0,100,1) | |
score = 0 | |
while True: | |
guess = input("Guess the number between 1 and 100? -- Type exit to end. ") | |
if guess.lower() == 'exit': | |
break | |
else: | |
gnum = int(guess) | |
if gnum > num: | |
print('lower') | |
score += 1 | |
elif gnum < num: | |
print('higher') | |
score += 1 | |
else: | |
score += 1 | |
print('Yay! The number was', num, '!') | |
if score <= 5: | |
print('You guessed it in only', score, 'tries!') | |
elif score <= 10: | |
print('You guessed it in', score, 'tries.') | |
else: | |
print('Better luck next time. It took you', score, 'tries.') | |
num = random.randrange(0,100,1) | |
score = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment