seats = 3
rating = 12
print('Hello and welcome to Daisy\'s cinema.')
while seats > 0:
name = input('What is your name?')
print('Hello',name,'\n')
print('We are currently showing Mockingjay at out cinema.')
film = input('What film would you like to watch?')
if film != 'Mockingjay' or 'mockingjay':
print('I\'m sorry but we aren\'t showing that film.\n\n')
else:
print('This film currently has',seats,'free seats and a certificate of',rating,'\n')
age = int(input('How old are you?'))
if age > 15 or age == 15:
print('You have booked a ticket to see this film.\n\n')
seats == seats-1
else:
print('I\'m sorry but you\'re too young to see this film.\n\n')
print('Mockingjay is now full. Thank you for booking your tickets. \n\n')
This piece of code simply isn't working. When I put in something other than Mockingjay or mockingjay for the film title, it works fine, but if I put these in it still says that this film isn't showing. When it should go on to say how many free seats there are and what the certificate is. Any ideas? I use Python 3.1.
Needs to be
Reason being that
or 'mockingjay'
is alwaysTrue
. (bool('mockingjay') = True
)Using
film.upper()
helps to ensure that regardless of the input case, eg:mocKinjay
,MOCKINgjay
,mockingjay
etc, it will always catch.If you want to check against 2 different strings then use either:
Notice the
and
, if we useor
here and pass inMockingjay
the statement would still evaluate becausefilm != 'mockingjay'
.