import re number = "123456789" result = re.findall("\d{1,2}", number) print(result) # ['12', '34', '56', '78', '9']import textwrap
s = ' '.join(textwrap.wrap(text='123456', width=2))print(s)