Insert elements in lists under array python
<p>I have a array consisting of tuples.</p>

<pre><code>Data = [('1234', 'abcd'), ('5678', 'efgh')]
</code></pre>

<p>I now have another set of variables in an array:</p>

<pre><code>add = ["#happy", "#excited"]
</code></pre>

<p>I'm trying to append 'add' to 'Data' in the same order such that the output should look like:</p>

<pre><code>data_new = [('1234', 'abcd', '#happy'), ('5678', 'efgh',"#excited")]
</code></pre>

<p>Is that possible? </p>

<p>You can add tuples in a list comprehension and use zip:</p>

<pre><code>&gt;&gt;&gt; [t+(e,) for t, e in zip(Data, add)]
[('1234', 'abcd', '#happy'), ('5678', 'efgh', '#excited')]
</code></pre>

<p>(works in Python 2 and 3)</p>

python arrays list python-2.7 tuples