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 assignment to the new list, to be based on the values of
> the first two items in each tuple.
>
>   If I try, for example, writing:
>
> for item in mainlist:
>     if mainlist[item][0] == 'eco' and mainlist[item][1] == 'con':
>       ec.Append(mainlist[item][2:])
>
> python doesn't like a non-numeric index.
>

try this instead:
for item in mainlist:
     if item[0] == 'eco' and item[1] == 'con':
       ec.append(item[2:])

if you want numeric adressing, try:
for i in range(len(mainlist)):
   if mainlist[i][0] == 'eco'  etc.





-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to