Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Using the Python not Operator (Summary)

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 not operator
  • Use the not operator 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:

To learn more about membership operators, check out Python’s “in” and “not in” Operators: Check for Membership.

You can also check out the video courses on the and and or operators:

Download

Sample Code (.zip)

3.3 KB
Download

Course Slides (.pdf)

1.1 MB

Become a Member to join the conversation.