On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote:
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple. I find references to sorting a list of tuples, but not
extracting tuples based on
Paddy kirjoitti:
On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote:
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple. I find references to sorting a list of tuples, but not
extracting
On 2007-02-25, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
Item is ALREADY the current tuple...
for tpl in mainlist:
if tpl[0] == eco and tpl[1] == con:
ec.Append(tpl[2:]) #presuming ec is NOT a list, as Append()
On Feb 25, 5:44 pm, Jussi Salmela [EMAIL PROTECTED] wrote:
Paddy kirjoitti:
On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote:
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple. I
[EMAIL PROTECTED] a écrit :
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple.
t = a, b, c
assert t[0] == a
assert t[1] == b
assert t[2] == c
I find references to sorting a list
On 2007-02-25, Paddy [EMAIL PROTECTED] wrote:
You might also use list comprehensions to accumulate the values you
need:
ec = [ item[2:] for item in mainlist if item[:2] == ['eco','con'] ]
Thank you, Paddy. That's the syntax I couldn't work out myself.
Rich
--
On 2007-02-25, Jussi Salmela [EMAIL PROTECTED] wrote:
I'm nitpicking, but the OP has a list of tuples:
ec = [ item[2:] for item in mainlist if item[:2] == ('eco','con') ]
Jussi,
An excellent nit to pick.
Thank you,
Rich
--
http://mail.python.org/mailman/listinfo/python-list
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple. I find references to sorting a list of tuples, but not
extracting tuples based on their content.
In my case, I have a list of 9
On Feb 25, 3:01 am, [EMAIL PROTECTED] wrote:
In my case, I have a list of 9 tuples. Each tuple has 30 items. The first
two items are 3-character strings, the remaining 28 itmes are floats.
I want to create a new list from each tuple. But, I want the selection of
tuples, and their
On Feb 25, 1:01 pm, [EMAIL PROTECTED] wrote:
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple. I find references to sorting a list of tuples, but not
extracting tuples based on
Rune Strand [EMAIL PROTECTED] writes:
if you want numeric adressing, try:
for i in range(len(mainlist)):
if mainlist[i][0] == 'eco' etc.
Preferable:
for i,m in enumerate(mainlist):
if m[0] == 'eco' etc.
--
http://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo