Python’s not
operator means that you can invert the fact worth of Boolean expressions and objects. You should use this operator in Boolean contexts, reminiscent of if
statements and whereas
loops. It additionally works in non-Boolean contexts, which lets you invert the reality worth of your variables.
Utilizing the not
operator successfully will make it easier to write correct detrimental Boolean expressions to regulate the movement of execution in your packages.
On this course, you’ll study:
- How Python’s
not
operator works - The way to use the
not
operator in Boolean and non-Boolean contexts - The way to use the
operator.not_()
perform to carry out logical negation - How and when to keep away from pointless detrimental logic in your code