Created
May 15, 2018 22:39
-
-
Save acwoss/a3e3be138eae1769f03eaa0a2828a75a to your computer and use it in GitHub Desktop.
QuixoticModernTelevisions created by acwoss - https://repl.it/@acwoss/QuixoticModernTelevisions
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 | |
target = randint(1, 100) | |
hit = False | |
hunches = set() | |
while not hit and len(hunches) < 10: | |
try: | |
hunch = int(input('Seu palpite:')) | |
if not 1 <= hunch <= 100: | |
raise ValueError('Palpite deve estar no intervalo [1, 100]') | |
if hunch in hunches: | |
raise ValueError('Você já deu este palpite antes') | |
if hunch == target: | |
hit = True | |
else: | |
hunches.add(hunch) | |
except ValueError as e: | |
print(e) | |
print('Venceu' if hit else 'Perdeu') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment