number_to_guess = random.randint(1, 10)
while True: догадка = input("Угадай число от 1 до 10: ")
Код: Выделить всё
# This crashes if 'guess' is not a number
if int(guess) == number_to_guess:
print("You won!")
break
else:
print("Wrong, try again.")
Код: Выделить всё
**The Problem:**
If I enter `hello`, I get: `ValueError: invalid literal for int() with bas
Подробнее здесь: https://stackoverflow.com/questions/798 ... while-loop
Мобильная версия