What Is the Fastest Way to Check if a Value Exists in a Python List?
The fastest way to check if a value exists in a Python list is by using the "in" keyword.
Example:
my_list = [1, 2, 3, 4, 5]
if 3 in my_list:
print("Value exists")
else:
print("Value does not exist")
Output:
Value exists