[EMAIL PROTECTED] writes: > for: s = "this . is a . test to . check if it . works . well . it looks > . like ." > the output should be (if grouping by 3) like: > > => this . > => this . is a .
I don't understand, you mean you have all the items in advance? Can't you do something like this? I got bleary trying to figure out the question, so I'm sorry if I didn't grok it correctly. def f(n, items): t = len(items) for i in xrange(-(n-1), t-n): print items[max(i,0):max(i+n,0)] s = 'this . is a . test to . check if it . works . well . it looks . like .' f(3, s.split('.')) >>> ## working on region in file /usr/tmp/python-306302aD... ['this '] ['this ', ' is a '] ['this ', ' is a ', ' test to '] [' is a ', ' test to ', ' check if it '] [' test to ', ' check if it ', ' works '] [' check if it ', ' works ', ' well '] [' works ', ' well ', ' it looks '] [' well ', ' it looks ', ' like '] -- http://mail.python.org/mailman/listinfo/python-list