Skip to main content

Membership Operators

Operators

Description

In

Returns true if a variable is in sequence of another variable, else false.

not in

Returns true if a variable is not in sequence of another variable, else false.

Example Program:

a=10 

b=20 

list=[10,20,30,40,50]; 

if (a in list): 

    print("a is in given list")

else: 

    print("a is not in given list") 

if(b not in list): 

    print("b is not given in list")

else: 

    print("b is given in list") 

Output:

a is in given list

b is given in list


Comments