problem of converting a list to dict
fredrik at pythonware.com
Wed Jan 9 20:05:39 CET 2008
Louis.Soninhu at gmail.com wrote:
> I have a list like this
> I'd like to remove the first and the last item as they are irrevalent,
> and convert it to the dict:
> I tried this but it didn't work:
> for i in mylist[1:-1]:
> and I got this:
> File "srch", line 19, in <module>
> File "srch", line 15, in grab
> IndexError: list index out of range
> Anyone could shed me a light on this?
works for me, with the mylist example you provided.
to see what's going on on your machine, try printing "a" after the
split, but before you use it to populate the dictionary.
More information about the Python-list