The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →For a Python list, use value in values. It evaluates to True when the value is a member and False otherwise. Use not in for the inverse result.
Check whether a list contains a value
Python’s in and not in operators test membership. For built-in sequences such as lists and tuples, a match is found when an element is identical to the searched value or equal to it.
As an Amazon Associate I earn from qualifying purchases.
values = [10, 42, 99]
if 42 in values:
print("found")
The condition is True, so the example prints found. To test for absence, write 42 not in values.
See the Python language reference for the membership operators and their semantics.
#1 Best Overall
How membership differs by container
The same syntax can ask different membership questions depending on the container. In a dictionary, in checks keys, not values:
record = {"name": "Ada", "role": "engineer"}
"name" in record # True: checks keys
"Ada" in record.values() # True: checks values
If you need to perform repeated membership checks, a set or dictionary may be a more suitable structure when its membership semantics fit your task. Choose based on what you need to store and check; the syntax alone does not make these containers interchangeable.
Rank #2
Python arrays and elementwise conditions
For a NumPy array, value in array_values asks whether the scalar is a member. NumPy documents ndarray.__contains__ as returning bool(key in self).
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →That differs from asking whether one or all elements meet a condition. A comparison such as array_values > 10 produces elementwise Boolean results. Reduce those results explicitly:
(array_values > 10).any() # True if at least one element is greater than 10
(array_values > 10).all() # True if every element is greater than 10
NumPy warns that testing the truth value of a multi-element array is ambiguous and raises an error; use .any() or .all() to express which result you want. For an elementwise equality question, use (array_values == value).any().
See NumPy’s ndarray reference for membership and array truth-value behavior.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What happens with a custom container
A custom Python object can define its membership behavior with __contains__(). If it has no such method, Python tries iteration, then the legacy indexed-sequence protocol. The Python data model documentation describes this fallback order.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




