interleave string
Andrea Crotti
andrea.crotti.0 at gmail.com
Tue Feb 15 04:53:56 EST 2011
More information about the Python-list mailing list
Tue Feb 15 04:53:56 EST 2011
- Previous message (by thread): Which is the best book to learn python
- Next message (by thread): interleave string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Just a curiosity not a real problem, I want to pass from a string like
xxaabbddee
to
xx:aa:bb:dd:ee
so every two characters insert a ":".
At the moment I have this ugly inliner
interleaved = ':'.join(orig[x:x+2] for x in range(0, len(orig), 2))
but also something like this would work
[''.join((x,y)) for x, y in zip(orig[0::2], orig[1::2])]
any other ideas?
- Previous message (by thread): Which is the best book to learn python
- Next message (by thread): interleave string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list