[Tutor] slicing nested lists/dicts/tuples

Reed L. O'Brien reed at intersiege.com
Tue Jun 28 23:02:25 CEST 2005


Reed L. O'Brien wrote:

>Luis N wrote:
>
>  
>
>>Hi,
>>
>>    
>>
>>>>>l
>>>>>          
>>>>>
>>[{'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'},
>>{'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'}]
>>
>>
>>This is how I imagine it:
>>
>>for i in l:
>>    for j in l[i]:
>>        for k in l[i][j]:
>>            print k.get('first')
>>            print k.get('last')
>>
>>Is there a short and sweet way of doing this (that actually works).
>>
>>Luis.
>>    
>>
>
>
>strings back:
>
>for i in l:
>    x = l[0].values()
>    x.reverse()
>    print " ".join(x)
>
>Foo Bar
>Foo Bar
>Foo Bar
>Foo Bar
>
>lists back:
>
>for i in l:
>    x = l[0].values()
>    x.reverse()
>    print x
>
>   
>['Foo', 'Bar']
>['Foo', 'Bar']
>['Foo', 'Bar']
>['Foo', 'Bar']
>
>~r
>
>
>  
>
I take that back now that I read it it is returning only the first one 4
times

oops
~r

-- 
4.6692916090
'cmVlZG9icmllbkBnbWFpbC5jb20=\n'.decode('base64')
http://www.spreadfirefox.com/?q=affiliates&id=16474&t=1




More information about the Tutor mailing list