[Tutor] Splitting long string into same len parts
John Fouhy
john at fouhy.net
Thu Feb 9 03:01:13 CET 2006
On 09/02/06, Victor Bouffier <victor at grupocdm.com> wrote:
> I'd like to split a long string into equally long strings (len(str) =
> 3). I did the following using regexes:
Remember that a string is just like a list (except that you can't modify it).
So, for instance:
>>> n = 'xb1jyzqnd1eenkokqnhep6vp692qi9tmag3owzqw0sdq3zjf'
>>> n[0:3], n[3:6]
('xb1', 'jyz')
Can you see how to generate the slice boundaries for the length you need?
--
John.
More information about the Tutor
mailing list