python while break try 无法中断_当条件为m时Python while循环不中断

我只是想知道,当循环满足这些条件并过滤到我的其他函数时,它为什么不中断?我做了一个whiletrue循环,并在每个if语句中插入了它,但我想知道这样做有什么不对。在

def main_入口():print "\n\tYou are in the main entrance. It is a large room with"

print "\ttwo doors, one to the left and one to the right. There"

print "\tis also a large windy stair case leading up to a second floor."

print "\n\tWhat are you going to do?\n"

print "\t #1 take the door on the left?"

print "\t #2 take the door on the right?"

print "\t #3 take the stairs to the second floor?"

choice = 0

#This seems to be the part that isn't working as I would expect it to.

# I have fixed it and have commented the fix out so that I can understand

# why this way isn't working.

#while True:

while (choice != 1) or (choice != 2) or (choice != 3):

try:

choice = int (raw_input ('> '))

if (choice == 1):

door_one_dinning_room()

#break (should not need this break if choice is == 1, 2, 3)

elif (choice == 2):

door_two_study()

#break

elif (choice == 3):

stairs_to_landing()

#there isn't anything in this function

#but rather than breaking out from the program once it is

# called, but somehow this while loop is still running.

#break

else:

print "You must pick one!"

except:

print "Please pick a number from 1-3"

continue

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值