python - Format a string with a space between every two digits -


input: string = 53434951

i need split string output reads: 53 43 49 51

you use like:

s = "534349511" print ' '.join([s[i:i+2] in range(0,len(s),2)]) 

note work lists of uneven length -- you'll have single digit @ end, after space.


Comments

Popular posts from this blog

c# - ItextSharp font color issue in ver 5.5.4+ -

jquery - Multiple issues with pushstate: history, loading, calling functions -

ios - retrievePeripherals deprecated in IOS7 how to substitude it with retrievePeripheralsWithIdentifiers -