Membership Operators
in and not in test whether a value is contained in a sequence, set or dict.
Beginner
"GND" in pins # list: linear search O(n)
"GND" in pin_set # set: hashing, O(1) on average
"R1" in resistors # dict: checks keys
"volt" in "voltage" # substring test
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.