May 2017
Intermediate to advanced
280 pages
6h 2m
English
Python has two membership operators to test the membership in a sequence, such as a string, list, tuple, and others:
|
Operator |
Description |
|
in |
Returns True if the specified operand is found in the sequence |
|
not in |
Returns True if the specified operand is not found in the sequence |
The following screenshot will make it clearer for you:

In the preceding screenshot, we try to search for the character, 'o', in the string, 'John', and it returns True. However, 'k' is not present in the string, and hence, it returns False.
Read now
Unlock full access