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 -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -