0

I am new to Python, and this is probably a very simple question, but I am having trouble figuring it out. I have some raw input that I need to convert. The input is a body of text such as 'ABCDEFGHIJKLMNO' but in order for me to continue, I need to convert this into a string such as 'ABC DEF GHI JKL MNO'.

1 Answers1

6
>>> s = 'ABCDEFGHIJKLMNO'
>>> ' '.join([s[i:i+3] for i in xrange(0, len(s), 3)])
'ABC DEF GHI JKL MNO'
arshajii
  • 127,459
  • 24
  • 238
  • 287