silly idea - interesting problem

Skip Montanaro skip at pobox.com
Sat Oct 20 16:24:01 CEST 2001


    >> ... a small script which takes to strings (lets say "test" and
    >> "dust") and mixes them to "tdeusstt".

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

There's always

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

or

    "".join(reduce(operator.add, zip('test', 'dust'), ())) 

Dunno if they are "easier" or "cleaner" however... ;-)

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list