silly idea - interesting problem
Emile van Sebille
emile at fenx.com
Sat Oct 20 10:47:08 EDT 2001
Another way to with list comprehensions:
''.join([ a+b for a,b in zip('test','dist') ])
--
Emile van Sebille
emile at fenx.com
---------
"Neal Norwitz" <neal at metaslash.com> wrote in message
news:3BD17C50.9D7D35AE at metaslash.com...
> 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