How to split string in equally long parts

Dan Bishop danb_83 at yahoo.com
Wed Apr 9 03:51:04 EDT 2003


"Mike Rovner" <mike at bindkey.com> wrote in message news:<mailman.1049836334.25959.python-list at python.org>...
> def split(S,N):
>   """S - source string
>      N - number of parts
>   """
>   lens=len(s)
>   l=lens/N

Don't you mean lens//N ?

>   return [S[i:i+l] for i in xrange(0,lens,l)]




More information about the Python-list mailing list