List splitting

Steven sfaulconer at gmail.com
Mon Aug 21 15:30:09 EDT 2006


Klaus Alexander Seistrup wrote:
> >>> t = [ "a", "b", "c", "n", "a", "a", "t", "t", "t" ]
> >>> [t[i::3] for i in range(3)]
> [['a', 'n', 't'], ['b', 'a', 't'], ['c', 'a', 't']]

Klaus,

Thanks for the fast reply! Had I taken the time to look at the
list-type docs (which I did to understand how you were spliting the
list), I'd probably have seen the slicing with step option. Another
RTFM issue for me.

Thanks again,
Steven




More information about the Python-list mailing list