On 3/14/06, Adam <[EMAIL PROTECTED]> wrote:

> Hopefully that should point you in the right direction to do n-sized
> words as well.

Indeed - as I now have a function:

def nsplit(s, n):
  return [s[i:i+n] for i in range(0, len(s), n)]

Incidentally I am currently going with:

def nsplit(s, n):
  while s:
   yield s[:n]
   s = s[n:]

As my friend just showed me how generators work, and also that the
beginning and end of lists are implicit.

Very cool.

Thanks for all your help!

S.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to