Help with creating a dict from list and range

Echo oshecho at gmail.com
Fri Oct 14 09:26:18 EDT 2005


Hello,
Here is what I am trying to do. I am trying to make a dict that has a key
that is the value an element in a list and the value for the dict to be the
index.
This is the closest I have been able to get:
dict((d[0],i) for d in self.cu.description for i in xrange(len(
self.cu.description)-1))

That however does not work. the value for all the dict is 40. Not 1, 2, 3,
... that I was hoping for.

Am I even close at creating the dict that I want? Is there a better way to
go about it?

--
-Echo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051014/1268306b/attachment.html>


More information about the Python-list mailing list