how do i merge two sequence

Peter Otten __peter__ at web.de
Thu Apr 19 02:54:28 EDT 2012


Ervin Hegedüs wrote:


> On Wed, Apr 18, 2012 at 10:41:00PM +0200, Peter Otten wrote:
>> Python Email wrote:
>> 
>> > how do i merge two seqs alernative;
>> > 
>> > ("xyz", "7890")
>> > output: x7y8z90
>> 
>> >>> import itertools
>> >>> "".join(a+b for a, b in itertools.izip_longest("xyz", "7890",
>> fillvalue=""))
>> 'x7y8z90'
> 
> why is this better than simple "".join(("xyz", "7890"))?

Have a second look at the desired output. Your suggestion doesn't produce 
that.




More information about the Python-list mailing list