James Kierans James Kierans - 2 months ago 7
Python Question

When i run the code, even if i type in a film on the list, it says that its not there and fails.What do i do?

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!")

J F J F
Answer

Your while condition will not match when the user inputs one of the film names. Instead, use this:

while choice not in list1:

This will find if choice is in list1. Also, instead of using else, you should do this:

while choice not in list1:
    # ...
print('Let’s go to times!')