The in Operator in Python


Check if an item exists in a list or a key exists in a dictionary.

Source Code

# In a list
print(1 in [1, 2, 3])

# In a dictionary
print("name" in {"name": "Alice", "age": 25})
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments