Most pythonic way to interleave two strings

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

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

For example:

Input:

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


        
14条回答
  •  庸人自扰
    2020-11-27 15:23

    Just to add another, more basic approach:

    st = ""
    for char in u:
        st = "{0}{1}{2}".format( st, char, l[ u.index( char ) ] )
    

提交回复
热议问题