[Tutor] Output of list
János Juhász
janos.juhasz at VELUX.com
Sun Dec 23 21:09:10 CET 2007
Dear Marty,
>... Or, by extending Alan's solution ...
>
>def splitStringByN(s, n):
> for m in range(0, len(s), n):
> yield s[m:m+n]
>
>k = 'abcdefghi'
>list(splitStringByN(k, 2))
It seems to be the most readable solution for me.
>As it turns out, this is similar to an ASPN Cookbook recipe contributed
>by Dmitry Vasiliev:
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302069
>
>HTH,
>Marty
Thanks for the link.
Best regards,
Janos
More information about the Tutor
mailing list