Most pythonic way to interleave two strings

前端 未结 14 1095
暗喜
暗喜 2020-11-27 14:34

What\'s the most pythonic way to mesh two strings together?

For example:

Input:

u = \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\'
l = \'abcdefghijklmnopqrst         


        
14条回答
  •  -上瘾入骨i
    2020-11-27 15:13

    Jim's answer is great, but here's my favorite option, if you don't mind a couple of imports:

    from functools import reduce
    from operator import add
    
    reduce(add, map(add, u, l))
    

提交回复
热议问题