Merge multiple lists horizontally in python
<p>I have two different lists like below</p>

<pre><code>A = [(Apple, Mango)]
B = [Grapes]
</code></pre>

<p>Now I would like to get a merged list as follows</p>

<pre><code>C = [(Apple,Mango,Grapes)]
</code></pre>

<p>Is there any predefined functions available in python to get above merged list.</p>

<p>Note: Already used zip method which is returning the result as different result</p>

<pre><code>C = [(Apple,Mango),(Grapes)]
</code></pre>

<p>The snippet of code which returned above result is this</p>

<pre><code>A = [('Apple','Mango')]
B = ['Grapes']

C = zip(A,B)

print C
</code></pre>

<p>here's an approach of flattening the tuple after the <code>zip</code>, it might perform less as for time complexity, but it will get what you want even for mixed type list, like <code>[str, tuple]</code> and <code>[tuple, str]</code></p>

<pre><code>a = [("apple", "mango"), "orange"]     # This is [tuple, str]
b = ["grapes", ("pineapple", "lemon")] # This one's [str, tuple]

flatten = ( lambda itr: sum(map(flatten, itr), tuple())
        if isinstance(itr, tuple) else (itr,)
         )

c = [flatten(x) for x in zip(a, b)]

print (c)
# [('apple', 'mango', 'grapes'), ('orange', 'pineapple', 'lemon')]
</code></pre>

python