tuple.index(item)

Robert Kern rkern at ucsd.edu
Tue Jul 12 03:41:53 CEST 2005


Jules Dubois wrote:
> On Monday 11 July 2005 15:23, David Isaac <aisaac0 at verizon.net>
> (<ArBAe.6857$Zy6.4547 at trnddc04>) wrote:
> 
>>Why don't tuples support an index method?
> 
>   19:27:32:~ $ python
>   Python 2.3.5 (#2, Jun 19 2005, 13:28:00)
>   [GCC 3.3.6 (Debian 1:3.3.6-6)] on linux2
>   Type "help", "copyright", "credits" or "license" for more information.
>   >>>
>   >>> t = ('a', 'b', 'c')
>   >>> t[1]
>   'b'
>   >>>

He means, rather

   t.index('b') == 1

as it works for lists.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list