def FilmSelection():
list1=["The Magnificent Seven",'Wreck It Ralph','James Bond','Now you see me 2','Captain America:The Winter Soldier']
choice=input("what film would you like to watch?")
while choice!=str(list1[1:5]):
print("sorry, that film is not available right now")
choiceb=input("would you like to select a different film?")
if choiceb=="yes"or choiceb=="Yes":
print("that's fine")
choice=input("what film would you like to watch?")
else:
print("have a nice day")
sys.exit()
else:
print("lets get to times!")
当用户输入其中一个电影名称时,您的while
条件将不匹配。相反,使用这个:
while choice not in list1:
这将发现如果choice
是in
list1
。此外,您应该这样做,而不是使用else
:
while choice not in list1:
# ...
print('Let’s go to times!')