Back
+10 XP
Concept

The in Operator

The `in` operator checks if an item lives inside a string, list, or collection:

python
print("py" in "python")        # True
print("gold" in ["wood", "iron"]) # False

# 53. The in Operator The `in` operator checks if an item lives inside a string, list, or collection: ```python print("py" in "python") # True print("gold" in ["wood", "iron"]) # False ``` It is lightning-fast, reads like spoken English, and replaces manual search loops. Negate it effortlessly: `if "ban" not in name:`.

Checkpoint

What does `"cat" in "scattered"` return?

Practice

Write an `if` checking if `"admin"` is in `allowed_users = ["alice", "bob", "admin"]`. If found, print `"Admin access approved"`.

Terminal
01
Tap code blocks below to assemble
Available Blocks