Мне просто интересно, почему цикл не прерывается, когда он удовлетворяет этим условиям и фильтрует его в мои другие функции? Я исправил это, выполняя цикл while и просто разбивая каждый оператор if, но я хотел бы знать, что не так с этим.Python while loop не прерывается при выполнении условий
Защиту main_entrance():
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
[Это] (http://stackoverflow.com/a/25860636/1189040) может быть лучшей альтернативой – Himal