So, there are two more useful operators
for producing Boolean values.
First, we're going to go over in and then we're going to go over its opposite not in.
So, in checks to see if the thing on the left is a member of the thing on the right.
So for example here,
suppose that we have a string apple and we want to
check if some substring is contained in that string.
So, the value of this expression is going to be true,
because the character p is an apple.
The value of this expression is going to be false,
because the character i is not an apple.
The value of this expression is going to be true,
because the substring AP is an apple.
And the value of this expression is going to be false,
because PA is not an apple.
So, I should get true, false, true, false.
So, if I print out is a in the string a then I should get true,
because yes, even though these two things are the same,
technically this is inside of this.
Same thing with if I spell out apple.
So, the value of both of these expressions will be true.
Somewhat weirdly, if I check to see if an empty string is contained in any other string,
then I'm going to get true.
So, is this empty string inside of the string a?
It's debatable what the answer should be,
but the way that Python evaluates this expression I get true.
So, if I check to see if this empty string is in the string apple,
I'm going to get true for this as well.
Now, the opposite of in is not in.
So, if I check to see if something is not in another string,
then I'm going to get true if it's not in that string.
So, x is not in apple.
So, the value of this overall expression is going to be
true because the string apple doesn't contain the character x.
So, somewhat confusingly, this not has
the same spelling as something like not Boolean expression,
but these are entirely different things.
They have the same function which is reversing the value of the Boolean expression,
so I'm saying not B is going to be true if B is
false in not in is going to be true if this is not in it,
but to Python, there are different kinds of expressions.
So, I just want to also illustrate that in also works with lists.
So, here if I check to see if this item is in this list,
I'm going to get the value false because it's
checking to see is there an item in this list,
whose value is just the string A,
even though I have some strings that happen to contain
As there's no item whose value is equal to A,
so I get false for this expression.
That's all for now until next time.