Код: Выделить всё
import random
random_num = random.randint(1, 100)
count = 1
while True:
try:
num = int(input("Guess the number? "))
if num == random_num:
print("Congrates! you guessed it.")
print("Tried:", count, "times")
play = input("Do you want to play again Y/N? ")
if play.lower() in ['n', 'no']:
quit()
elif play.lower() in ['y', 'yes']:
random_num = random.randint(1, 100)
count = 1
else:
quit()
elif num > random_num:
print("Not yet, smaller.")
elif num < random_num:
print("Not yet, Greater.")
else:
quit()
count += 1
except:
print("Oops! please enter a valid number.")
Когда я запускаю хороший и выбирай или нет он застрял в бесконечном цикле
Код: Выделить всё
Guess the number? Oops! please enter a valid number.
Подробнее здесь: https://stackoverflow.com/questions/790 ... play-again