[BangPypers] List Problem..

Anand Balachandran Pillai abpillai at gmail.com
Sat Jul 24 10:05:43 CEST 2010


On Sat, Jul 24, 2010 at 10:09 AM, anuj abhishek <anuj_abhishek at yahoo.com>wrote:

> I am not very sure about what you are asking for..
> But, if it's just a dictionary that you want from the given list then I
> beleive
> the folloeing will work..
> >>> x=[['cat',30],['cat',40],['cat',10],['dog',5],['dog',7],['dog',1]]
> >>> x= sorted(x)
> >>> xdictstart=dict(zip([x[0][0],x[3][0]],[x[0][1],x[3][1]]))
> >>> xdictstart
> {'dog': 1, 'cat': 10}
> And similarly for dictend..
> Regards,
> Anuj
>

Thank you for posting. Please try to trim the message backlog
when replying. In your email, your reply was like 10% and the
long tail made up 90% of the rest. It just adds up to the noise.

--Anand


More information about the BangPypers mailing list