inAdvanced Playground

Membership test operator; also used in for loops to iterate over items

Python Playground
Output
Click "Run" to execute your code

Implement __contains__ for O(1) membership testing. Without it, Python falls back to iterating through __iter__, which is O(n).

Challenge

Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?