Member index in toples

Klaus Alexander Seistrup klaus at seistrup.dk
Thu Jun 1 14:29:26 EDT 2006


A.M skrev:

> I have a tuple like this:
>
> T = ("One","Two","Three","Four")
>
> Is there any built-in way to find what is the index of "Two" 
> withouot looping within the tuple?
>
> Is the same feature available for lists or dictionaries?

Lists have an index method:

#v+

>>> L = list(T)
>>> L.index('Three')
2
>>> 

#v-

Dictionaries are unordered and hence indices don't make much sense.

Mvh, 

-- 
Klaus Alexander Seistrup
SubZeroNet, Copenhagen, Denmark
http://magnetic-ink.dk/



More information about the Python-list mailing list