<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.12.1">
</HEAD>
<BODY>
I have a program that keeps some of its data in a list of tuples.  Sometimes, I want to be able to find that data out of the list.  Here is the list in question:<BR>
<BR>
<TT>[('password01', 'unk'), ('host', 'dragonstone.org'), ('port', '1234'), ('character01', 'Thessalus')]</TT><BR>
<BR>
For a regular list, I could do something like x.index('host') and find the index of it, but I don't know how to do this for a tuple where the data item isn't known in advance.  For example, I want to get the "host" entry from the list above; but I can only retrieve it if I know what it contains (e.g., x.index(('host', 'dragonstone.org'))).<BR>
<BR>
Is there a better way to do this than a construct similar the following?<BR>
<BR>
<TT>for key, value in x:</TT><BR>
<TT>    if key == 'host':</TT><BR>
<TT>        print value</TT><BR>
<BR>
Thanks in advance!<BR>
<BR>
    — Mike<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
--<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
Michael B. Trausch
</TD>
<TD>
<DIV ALIGN=right><A HREF="mailto:fd0man@gmail.com">fd0man@gmail.com</A></DIV>
</TD>
</TR>
<TR>
<TD>
Phone: (404) 592-5746
</TD>
<TD>
<DIV ALIGN=right>Jabber IM: fd0man@livejournal.com</DIV>
</TD>
</TR>
</TABLE>
<BR>
Demand Freedom!  Use <I>open</I> and <I>free</I> protocols, standards, and software!
</TD>
</TR>
</TABLE>
</BODY>
</HTML>