Sign in to follow this  

or operation in python?

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey im busy creating my first game in python:D but i've a question: is there a or ( in C++ ||) operator?

Share this post


Link to post
Share on other sites
hehe didn't know it was that simple:P but if i do this:

if YN != "Y" or "y" or "N" or "n":
print "Not a valid option"



it doesnt work. what's wrong with it?

Share this post


Link to post
Share on other sites
Quote:
Original post by jordi_0071
cant you use the !=?


Yes, but not in that way. You would need to do this:

if YN != "N" or YN != "n" or YN != "Y" or YN != "y"

But python is a great language and has many more expressive ways to do things:

if YN not in ("Y", "y", "N", "n"):

Share this post


Link to post
Share on other sites
Sign in to follow this