SyntaxError: invalid syntax в Питоне 3
Написал программу, которая загадывает число от 1 до введенного числа, и игроку надо его угадать, но на проверке введенного числа выдает SyntaxError. Что я делаю не так?
from random import randint
top = int(input('Input a highest possible number. '))
rand_number = randint(1, top)
attempt = 0
while 1 == 1:
guess = (input('Input your guess. ')
if 1 > guess or guess > top: # Если guess вне [1, top], отсюда начинаются ошибки.
print('Are you giving up? Y/N ')
answer = input()
if answer in ['N', 'n', 'No', 'no', 'NO']:
print("OK, we are back to the game!")
continue
else:
print('GAME OVER')
break
Ответы (2 шт):
Автор решения: Victor VosMottor
→ Ссылка
from random import randint
top = int(input('Input a highest possible number: '))
rand_number = randint(1, top)
attempt = 0
while True:
guess = int(input('Input your guess: '))
if guess not in range(1, top):
answer = input('Are you giving up? Y/N ')
if answer.lower() in ('n', 'no'):
print("OK, we are back to the game!")
continue
elif answer.lower() in ('y', 'yes'):
print('GAME OVER')
break