You should use and
operator instead of or
operator. To avoid such confusion, you can try and write such conditions in close to english way, like this
cont="a"
if cont not in ("n", "y"):
print "Welcome"
This can be read as "if cont is not one of...". The advantage of this method is that, you can check for n number of elements in a single condition. For example,
if cont not in ("n", "y", "N", "Y"):
this will be True
only when cont
is case-insensitively n
or y
Edit: As suggested by Eric in the comments, for single character checking we can do something like this
if cont not in "nyNY":