Skip to content

Instantly share code, notes, and snippets.

@acwoss
Created May 15, 2018 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acwoss/a3e3be138eae1769f03eaa0a2828a75a to your computer and use it in GitHub Desktop.
Save acwoss/a3e3be138eae1769f03eaa0a2828a75a to your computer and use it in GitHub Desktop.
QuixoticModernTelevisions created by acwoss - https://repl.it/@acwoss/QuixoticModernTelevisions
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