Why can't I use OR in if statement?
I found out that I have to .lower the input. But I first tried with 'n' or 'N'. And that didn't work. Seemed logical that it would. Why doesn't it work?
import sys start = input('want to start the movie? ') if start != 'n' or 'N': print ('Enjoy the show!') else: sys.exit()
Jason AndersTreehouse Moderator 144,840 Points
You're doing really well so far, there are just a couple of things.
First, when checking multiple conditions on the same line, everything needs to be repeated for the subsequent conditions. Instead of:
if start != "n" or "N":
It needs to be:
if start != "n" or start != "N":
Make sense? Each condition needs to be told again what it is comparing to.
Second, you can't use
or in this example. With
or, only one of the conditions has to evaluate to
True to pass. So, the first check is looking for
not equal to a lower case 'n'... if someone puts in an upper-cased "N" then this returns True as it is Not Equal to the lower case and will trigger the
if block, and the second condition will not even run.
and, both must return true to execute. So, an upper-cased "N" passes the first condition, but gets 'caught' on the second so the whole line returns
False and the program executes the
I hope that makes sense!
Other wise, nice work. Just one more tip. in python, it is the convention to not have a space separating the method and the parameters. So,
print ('Enjoy the show!') should be
print('Enjoy the show!'). The former won't cause an error, but it should be the latter.
Keep Coding! :)
ah ofc. that makes sense :)
those not not true and or false are still messing with my brain. Will need to spend some more times with the not not true bools :p
Thank you on the space "issue". Just a habit that I need to relearn.