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

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -