Q:

python, string methods

Possible Duplicate:
Pythonic way to insert every 2 elements in a string 

I'll be happy if someone can help with python code)) 
How can I put the space into a string
for example,
If there is the string 'akhfkahgdsds'
I would like to turn it into 'ak hf ka hg ds ds'

A:

>>> s = 'akhfkahgdsds'
>>> range(0, len(s), 2) # gives you the start indexes of your substrings
[0, 2, 4, 6, 8, 10]
>>> [s[i:i+2] for i in range(0, len(s), 2)] # gives you the substrings
['ak', 'hf', 'ka', 'hg', 'ds', 'ds']
>>> ' '.join(s[i:i+2] for i in range(0, len(s), 2)) # join the substrings with spaces between them
'ak hf ka hg ds ds'

