[Tutor] Finding the Index of a member of a Tuple

Steve Haley sfhaley at gmail.com
Thu Jan 12 05:31:04 CET 2006


Hello everyone,

I need to do something very simple but I'm having trouble finding the way to
do it - at least easily.  I have created a tuple and now need to find the
position of individual members of that tuple.  Specifically, the tuple is
something like: words = ("you", "me", "us", "we", "and", "so", "forth") and
I need to be able to name a member, for example, "us" and find what the
position (index) of that word is in the tuple.

I would have thought there would be a simple built in function for that but
I just went through the built in functions in the Python Library Reference
and I didn't find anything.  I could probably figure out how to write a
while loop or something to do a sequential search until I found the right
member but I really believe there must be an easier way and I'm just not
seeing it.  You can probably tell I'm just learning Python so any help would
be appreciated.

Thanks very much in advance,
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060111/d8b18736/attachment.html 


More information about the Tutor mailing list