[EMAIL PROTECTED] wrote: > I have a list like this > > mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > I'd like to remove the first and the last item as they are irrevalent, > and convert it to the dict: > {'tom':'boss','mike':'manager','paul':'employee'} > > I tried this but it didn't work: > > mydict={} > for i in mylist[1:-1]: > a=i.split('=') > mydict[a[0]]=a[1] > > and I got this: > File "srch", line 19, in <module> > grab("a/tags1") > File "srch", line 15, in grab > mydict[mylist[0]]=mylist[1] > 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. </F> -- http://mail.python.org/mailman/listinfo/python-list