[portland] Still Having List/Tuple Problems
rshepard at appl-ecosys.com
Wed Apr 16 20:48:45 CEST 2008
I have a mental block on understanding just how to index a list of tuples
so I can extract the data in an orderly fashion.
The list looks like this: [(A,1),(A,2), ... (A,8),(B,1),(B,2), ...
(B,8),(C,1),(C2), ... (C,8)]
What I want to do is extract all tuples grouped by the first element, then
list the associated second elements). That is,
Referencing list returns the first tuple; list returns the first
item in the first tuple; but I cannot cycle through the three first items
extracting the second items associated with each.
I've looked at my books and previous threads here, but I'm just not
getting how this is done. I've played with list comprehensions, zip, and
other tools without getting the proper syntax or results I need. Don't know
why the answer keeps eluding me, but it does.
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
More information about the Portland