We use membership operators to check whether a value or variable exists in a sequence (string, list, tuples, sets, dictionary) or not.
Operator | Syntax | Description | Example |
---|---|---|---|
in | x in y | This returns True if x exists in sequence in y |
x = "Hello, World!" |
not in | x not in y | This returns True if either x does not exist in sequence in y |
x = "Hello, World!" print("hello" not in x) |
Example
You are expected to comply with University policies and guidelines namely, Appropriate Use of Information Resources Policy, IT Usage Policy and Social Media Policy. Users will be personally liable for any infringement of Copyright and Licensing laws. Unless otherwise stated, all guide content is licensed by CC BY-NC 4.0.