Skip to Main Content

Python for Basic Data Analysis

Start your data science journey with Python. Learn practical Python programming skills for basic data manipulation and analysis.

Membership operators

Membership operators 

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!"
print("ello" in x)

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)


Video Guide


Use the operators to solve for the following equations.

1. Is 200 in "200 years ago?"
2. Is "apples" in this list ["apple", "bananas", "cherries"]
3. "et" is not in "Let's go for a meal!" True or False?