not in Negated membership
Last updated: 2026-09-22
not in Negated membership
not in is the negation of in.
| Category | Operators |
|---|---|
| Kind | Operator |
| Python Version | all |
📝 Syntax
x not in container
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
True
True
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QIs not in the same as not (x in lst)?
AYes. `not in` is simply the negation of `in`, just written more naturally and readably. Prefer writing `x not in lst` over `not x in lst`.
QFor strings, does not in mean substring-not-match?
AYes. `'z' not in 'xyz'` is `False` (`z` is in the string), while `'w' not in 'xyz'` is `True`.
QCan I write not in inside a for loop?
ANo. The `for` iteration syntax only supports `in` (`for x in lst`); `not in` can only be used as a membership-test expression, returning `True`/`False`.