所以,我一直在制作一个基于文本的冒险游戏,它会询问你的年龄。如果您的年龄小于 13 岁,则退出游戏,如果年龄大于或等于,则允许您玩。我现在要做的是让它,所以如果年龄不是一个数字,它会要求你租用年龄,所以有点重播脚本。
有没有办法做到这一点?
age = input()
if age >= 13:
print("You are old enough to play! Let's get started!")
elif age != int:
print("This is not a number")
(该语法不起作用,而且我希望它让您再次输入您的年龄以进行验证。)
else:
print("You are not old enough.")
time.sleep(1)
sys.exit("Please exit the console, you are too young to play.")