in operator

The operator that tests whether a value is contained in a string, list, tuple, set or dictionary, giving True or False.

In more detail

"ss" in "Mississippi" tests for a substring; 3 in nums for a list item; "key" in d for a dictionary key. not in is the negation. It is fast for sets and dictionaries and slower for long lists, which must be searched item by item.

Example

"a" in "cat"   # True

Related terms

Taught in

References

Certification courses