[('password01', 'unk'), ('host', 'dragonstone.org'), ('port', '1234'), ('character01', 'Thessalus')]
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'))).
Is there a better way to do this than a construct similar the following?
for key, value in x:
if key == 'host':
print value
Thanks in advance!
— Mike
--
Demand Freedom! Use open and free protocols, standards, and software! |
-- http://mail.python.org/mailman/listinfo/python-list