ericdaniel wrote: > I'm new to Python and I need to do the following: > > from this: s = "978654321" > to this : ["978", "654", "321"]
Use a loop: >>> s = "978654321" >>> items = [] >>> for start in range(0, len(s), 3): ... items.append(s[start:start+3]) ... >>> items ['978', '654', '321'] or a list comprehension: >>> [s[start:start+3] for start in range(0, len(s), 3)] ['978', '654', '321'] Peter -- http://mail.python.org/mailman/listinfo/python-list