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
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
- Use the
notoperator in Boolean and non-Boolean contexts
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:
- Python Booleans: Optimize Your Code With Truth Values
- Operators and Expressions in Python
- Using the “and” Boolean Operator in Python
- Using the “or” Boolean Operator in Python
You can also check out the video courses on the
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.