Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator not in

Tests whether membership in the right operand fails.

Version: Python 3.14; repository image, production runtime not attested

Syntax

left not in right

Tests whether membership in the right operand fails.

Use the negated containment test to reject duplicate keys before insertion or to check that a forbidden substring is absent. It returns a Boolean.

The underlying membership search still executes, including its side effects. A search that fails on a one-pass iterator leaves it exhausted.

The empty string is a substring of every string.

Syntax

left not in right

__contains__, __iter__, __getitem__ · not in

Worked example

7 not in {"x": 7} → True
"" not in "abc" → False

Examples

print("x" not in {"y": "x"})
print("" not in "abc")

Result

True
False

The empty string is a substring of every string.

Sources