Using "in" operator with list

"in" is an identity operator in Python. ."in" operator in Python checks if a specific element is part of the list or tuple or strings. 

"in" operator returns TRUE if the specified element is in list, returns FALSE if the specified element is not present in list

Example as below:

#a list is declared
num = ['1','2','3','4','5','6']

if 5 in num:
    print("Element found")
else:
    print("Element not found")

Post a Comment

0 Comments