AI engineering glossary · Python core

What is membership operator?

Membership operator: The in and not in operators, which test whether a value occurs inside a container such as a string, list, tuple, set or dictionary. For dictionaries the test applies to keys. Lookup in sets and dictionaries is much faster than in lists.

Level: beginnerTopic: Python core

Membership operator: an example

'a' in 'banana' is True, 3 in [1, 2] is False, and 'name' in {'name': 'Ravi'} is True.

Related terms

More Python core terms

Where you learn it

Membership operator is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.