python manipulations on lists
<p>I have 2 lists</p>

<pre><code>l1 = ('A','B','C')
l2 = ('X','Y','Z')
</code></pre>

<p>I want to create a list based on these 2 </p>

<p>result = ('A is same as X', 'B is same as Y', 'C is same as Z')</p>

<p>when I concatenate , I do not get the result I expect
How can I combine the lists ?
Thanks
PMV</p>

<p>You can <code>zip</code> the lists together which will combine the two lists into a list of tuples and then iterate over those tuples.</p>

<pre><code>z = zip(l1,l2) #[(A,X), (B,Y), (C,Z)]

result = ["{0} is the same as {1}".format(t[0], t[1]) for t in z]

# ['A is the same as X', 'B is the same as Y', 'C is the same as Z']
</code></pre>

python string list data-manipulation