I have 2 lists

X=

Y=

I need to make a new list Z such that,

Z =

I know this uses simple concatenation. I tried several times but without success. I am a beginner so please help me with the code. Thanks in advance.

>>> Z = []
>>> X=['a']
>>> Y=['b','c','d','e','f']
>>> for i in Y:
...     Z.append(X[0] + i)
...     
>>> Z
['ab', 'ac', 'ad', 'ae', 'af']
>>>

You can also write Z = [x+y for x in X for y in Y] .

commented: sweet +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.