It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

# Python for Basic Data Analysis: 1.12 Membership operators

Get started on your learning journey towards data science using Python. Equip yourself with practical skills in Python programming for the purpose of 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)

Example

## Exercises

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?