Наложение списков

Есть списки a и b одинакового размера. Нужно наложить их друг на друга так, чтобы получился список c такого же размера, каждый элемент которого - комбинация элементов a и b, стоящих на том же месте. Например:

a = [
    'color', 'blue', 'red',
    'black', 'color', 'yellow',
    'green', 'color', 'gray'
]
b = [
    '', '', '1',
    '', '', '2',
    '', '', '3'
]

Результат:

c = [
    'color', 'blue', '1ed',
    'black', 'color', '2ellow',
    'green', 'color', '3ray'
]

Ответы (3 шт):

Автор решения: Evgenii Evstafev
a = ['color', 'blue', 'red',
     'black', 'color', 'yelow',
     'gren', 'color', 'gray']
b = ['', '', '1',
     '', '', '2',
     '', '', '3']

c = []
for a_item, b_item in zip(a, b):
    if b_item:
        c.append(b_item + a_item[len(b_item):])
    else:
        c.append(a_item)

print(c) # >> ['color', 'blue', '1ed', 'black', 'color', '2elow', 'gren', 'color', '3ray']
→ Ссылка
Автор решения: u111
a = [
    'color', 'blue', 'red',
    'black', 'color', 'yellow',
    'green', 'color', 'gray'
]
b = [
    '', '', '1',
    '', '', '2',
    '', '', '3'
]

c = []
list_length = len(a)
for i in range(list_length):
    string1 = a[i]
    string2 = b[i]
    result_string = string2 + string1[len(string2):]
    c.append(result_string)

print(c)
→ Ссылка
Автор решения: CrazyElf

Ну, тут можно в одну строку, используя списковые сокращения и срезы:

c = [f'{y}{x[len(y):]}' for x, y in zip(a, b)]
→ Ссылка