finding a value in a tuple

Sean 'Shaleh' Perry shalehperry at home.com
Thu Nov 29 22:01:24 CET 2001


On 29-Nov-2001 Dan Allen wrote:
> Say I have
> 
> mylist = ['one','two','three']
> 
> which I presume is a "tuple" as I have been scanning the manual.  Now,
> is there a way to run the php-like function in_array() on this. 
> Consider this, I want to know if one of the values in that tuple is
> exactly equal to "four".  The answer of course is no, but how would I
> find it.  Here is what I have so far, which works, but it is ugly..
> 

[] => list, () => tuple

if 'one' in mylist:
   print "found it"

if 'bob' in mylist:
   print "hi bob!"

only the first on succeeds.




More information about the Python-list mailing list