How to concatenate element-wise two lists in Python?

后端 未结 8 2503
春和景丽
春和景丽 2020-11-29 02:24

I have two lists and I want to concatenate them element-wise. One of the list is subjected to string-formatting before concatenation.

For example :

         


        
8条回答
  •  暖寄归人
    2020-11-29 03:07

    b = ['asp1', 'asp1', 'asp1', 'asp1', 'asp2', 'asp2']
    aa = [0, 1, 5, 6, 10, 11]
    new_list =[]
    if len(aa) != len(b):
         print 'list length mismatch'
    else:
        for each in range(0,len(aa)):
            new_list.append(b[each] + str(aa[each]))
    print new_list
    

提交回复
热议问题