silly idea - interesting problem

Neal Norwitz neal at metaslash.com
Sat Oct 20 09:29:52 EDT 2001


Stefan Antoni wrote:
> 
> i got a silly idea about a small script which takes to strings (lets say
> "test" and "dust") and mixes them to "tdeusstt".
> i tried to code it because i thought it would be easy, but now i cannot
> find out _how_ to do it ;)
> 
> i tried to "list()" the string and mix the items. but ...
> 
> Anybody has a hint or even a solution?

  ''.join([ a for x in zip('test', 'dust') for a in x ])

Can't think of an easier (or cleaner) way.

Neal



More information about the Python-list mailing list