Account
Categories

List Membership (in / not in) Operation


Definition:

It checks whether the data is present or not in a list using the membership operator (in / not in).

Syntax:

value in list
value not in list

Example:

a = [15, 8, 30]

print(8 in a)
print(40 not in a)

Output:

Exercise

Create a list a = [5, 10, 15] and check whether 10 is in the list using Python.