In Python, what is the efficiency of the in keyword, such as in:
in
a = [1, 2, 3] if 4 in a: ...
The complexity for lists is:
O(n)
For sets it is:
O(1)
http://wiki.python.org/moin/TimeComplexity
2.1m questions
2.1m answers
60 comments
57.0k users