Python in Keyword

Used to check if a value is present in a list, array etc. When used with an if statement or in an expression, in returns True or False depending on whether a value in a collection.

Example

Python
if 'e' in 'Hello':
    print("e is in the word Hello")

inList = 5 in [3, 4, 5]
print(inList)

Output

e is in the word Hello
True

The in keyword is also used with for loops:

Python
for x in range(1, 3):
    print(x)