in operator in Python

in operator is used in Python to find if a specific item is present in the list or not. Below is a code to explain the same.

list = [1,2,3,4,5,6,34,54,21,78]
print(78 in list)
print(33 in list)

In the program a list is defined and using in operator it is checked if a specific item is part of the list or not. When in operator is used, the output is either True of False. As per this, the output is True with the first statement and as 78 is present in the list and output is False in the second statement as 33 is not present in the statement.

Post a Comment

0 Comments