Completion requirements
This Book deals with What is an Operator and what are the various operators in Python.
Note : This section is mandatory to complete.
7. Membership Operators
- Membership operators are used to test whether specific value or item is present is a sequence or a collection of items. There are two membership operators in python. They are 'in' , 'not in'. These operators are generally used with Strings, Lists, Tuples, Sets and Dictionaries to check for the existence of values.
|
Operator |
Description |
Example |
|
in |
Returns True if specific value is present in a sequence or a collection. Otherwise, it returns False. |
X=[1,2,3] 2 in X - True 10 in X - False |
|
not in |
Returns True if specific value is not present in a sequence or a collection. Otherwise, it returns False. |
Y=(1,2,3) 8 not in Y - True 2 not in Y - False |