Find out if a Python array contains an element/value 

Joined:
04/09/2007
Posts:
773

December 25, 2009 00:13:19    Last update: December 25, 2009 00:13:19
Use the in operator to find out if a Python array contains an object:

>>> a = [1, 2, 3]
>>> 1 in a
True
>>> 3 in a
True
>>> 5 in a
False
>>> '1' in a
False
>>>
Share |
| Comment  | Tags