Newbie question on tuples
Carmine Noviello
cnoviello at hotmail.com
Thu Feb 5 16:30:12 EST 2004
"Thomas Philips" <tkpmep at hotmail.com> wrote in message
news:b4a8ffb6.0402051309.4292ccf1 at posting.google.com
> How does one find the position of an item in a tuple. i.e. If the
> tuple is ("rock", "scissors", "paper"), what function (or method) do I
> call with "rock" to get 0 or with "paper" to get 2?
>
> Thomas Philips
def indexOf(t, elem):
ret = -1 #Not in tuple
for i in range(len(t)):
if t[i] == elem:
ret = i
break
return ret
-Bye
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
More information about the Python-list
mailing list