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

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

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.