我正在创建一个向用户显示Monty Hall问题的程序,但是由于某些原因,在用户输入后python将无法打印
我尝试通过执行val = int(whichDoor)
来使用户输入一个int,但这没有用。我还尝试将代码中的“输入”更改为“ raw_input”,这没有任何帮助。我还尝试将“ int”放在(door1),(door2)和(door3)的前面,但这也无济于事。现在,这个问题被标记为重复题,我尝试了重复题解决方案,但对我没有帮助。
from random import randrange
door1 = (randrange(1, 3))
door2 = (randrange(1, 3))
door3 = (randrange(1, 3))
print("There are 3 doors, 1 has $1,000,000,000! the other two have nasty rotten ONIONS!")
whichDoor = input("Which door would you like to choose? Door 1, 2, or 3? ")
if whichDoor == 1:
print("you chose " + int(door1) + "!")
elif whichDoor == 2:
print("you chose " + int(door2) + "!")
elif whichDoor== 3:
print("you chose " + int(door3) + "!")
else:
exit
预期结果是python打印用户选择的门随机数。根据终端,没有错误。