请教一下,如何在用int(input())函数时候输入字符串时候可以不出错
谢谢各位大神,帮帮我,我需要的的确是整数,但怎么才可以输入了字符串也不会出错呢?print('You enter a dark room with two doors.\nDo you go through oor #1 or door #2?')
door = int(input('>'))
if door == 1:
print('There\'s a giant bear here eating a cheese cake.')
print('what do you do?')
print('1.Take the cake. \n2.Scream at the bear.')
num = int(input('>'))
for i in range(1):
if num == 1:
print('The bear eats your face off.\tGood job!')
if num == 2:
print('The bear eats your legs off.\tGood job!')
else:
print(f'{num} is not option, do it agains.')
continue
else:
print('you\'re dead')