-
-
Save anonymous/c5bee8d125986bc911da to your computer and use it in GitHub Desktop.
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
import random | |
yourNumber = None | |
while True: | |
try: | |
yourNumber = int(input('Enter a number between 1 and 100: ')) | |
if yourNumber > 100 or yourNumber < 1: | |
print('Please enter a number between 1 and 100!') | |
continue | |
break | |
except ValueError: | |
print('That is not a number, try again!') | |
computerGuesses = list() | |
while True: | |
computerGuess = random.randint(1, 100) | |
if not computerGuesses.__contains__(computerGuess): | |
computerGuesses.append(computerGuess) | |
if computerGuess == yourNumber: | |
print('Your number is:', computerGuess) | |
break | |
else: | |
print('Not', computerGuess) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment