Python’s not is a logical operator that inverts the truth value of Boolean expressions and objects. It’s handy when you need to check for unmet conditions in conditional statements and while loops.
You can use the not operator to help you decide the course of action in your program. You can also use it to invert the value of Boolean variables in your code.
In this course, you learned how to:
- Work with Python’s
notoperator - Use the
notoperator in Boolean and non-Boolean contexts - Use
operator.not_()to perform logical negation in a functional style - Avoid unnecessary negative logic in your code whenever possible
If you’d like to learn more about Boolean operations in Python, then check out the following tutorials:
