For each element in list of lists, merge with corresponding value in a separate flat list

let’s say I have two lists:

lst1 = [['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c']]
lst2 = ['x', 'y', 'z']

And I want to combine both such that the output would look like:

output = [['ax', 'bx', 'cx'], ['ay', 'by', 'cy'], ['az', 'bz', 'cz']]

Can I do this with only list comprehension? Using zip() I tried the following line of code

output = [[x + y for x,y in zip(sublist, lst2)] for sublist in lst1]

but as expected it yielded [['ax', 'by', 'cz'], ['ax', 'by', 'cz'], ['ax', 'by', 'cz']]. I am trying to build on this line of code to get my desired output. but not sure where to go from here.

I am thinking that I may need to access the indices in lst2 using enumerate() so that I can apply only the strings in lst2[0] to the first sublist, thenlst2[1] to the second sublist, etc etc. Can this be done with list comprehension?


Here is a solution you can give it a try,

lst1 = [['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c']]
lst2 = ['x', 'y', 'z']

    [[ii + j for ii in i] for i, j in zip(lst1, lst2)]

[['ax', 'bx', 'cx'], ['ay', 'by', 'cy'], ['az', 'bz', 'cz']]