Re: printing out elements in list

2006-05-08 Thread micklee74
thanks for the detailed explaination... i know about basic lists slicing..just havn't seen one with "steps" yet.. thanks again...clp rocks. -- http://mail.python.org/mailman/listinfo/python-list

Re: printing out elements in list

2006-05-08 Thread Tim N. van der Leeuw
alist[::2] means taking a slice. You should look up slice-syntax in the tutorials and reference manual. in general, alist[1:5] means: take list elements position 1 up to (excluding) 5. (List indexing starts at position 0, so the first element in the list is not included!) alist[0:5] means: take l

Re: printing out elements in list

2006-05-08 Thread micklee74
thanks for all your replies...I will go test them out.. I was wondering what does this mean alist[1::2]? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: printing out elements in list

2006-05-08 Thread I V
On Mon, 08 May 2006 00:44:39 -0700, micklee74 wrote: > i have a list with contents like this > alist = ['>QWER' , 'askfhs', '>REWR' ,'sfsdf' , '>FGDG', > 'sdfsdgffdgfdg' ] > > how can i "convert" this list into a dictionary such that > > dictionary = { '>QWER':'askfhs' , '>REWR' : 'sfsdf' , '>FGD

Re: printing out elements in list

2006-05-08 Thread Tim N. van der Leeuw
Using slices and built-in zip: >>> alist = ['>QWER' , 'askfhs', '>REWR' ,'sfsdf' , '>FGDG', 'sdfsdgffdgfdg' ] >>> dict(zip(alist[::2], alist[1::2])) {'>QWER': 'askfhs', '>FGDG': 'sdfsdgffdgfdg', '>REWR': 'sfsdf'} Slightly more efficient might be to use izip from itertools: >>> from itertools imp

printing out elements in list

2006-05-08 Thread micklee74
hi i have a list with contents like this alist = ['>QWER' , 'askfhs', '>REWR' ,'sfsdf' , '>FGDG', 'sdfsdgffdgfdg' ] how can i "convert" this list into a dictionary such that dictionary = { '>QWER':'askfhs' , '>REWR' : 'sfsdf' , '>FGDG', 'sdfsdgffdgfdg' } thanks -- http://mail.python.org/mailm