How to merge the elements in a list sequentially in python
<p>I have a list <code>[ 'a' , 'b' , 'c' , 'd']</code>. How do I get the list which joins two letters sequentially i.e the ouptut should be <code>[  'ab', 'bc' , 'cd']</code> in python easily instead of manually looping and joining</p>

<p>Just one line of code is enough :</p>

<pre><code>a = ['a','b','c','d']
output = [a[i] + a[i+1] for i in xrange(len(a)) if i &lt; len(a)-1]
print output
</code></pre>

python python-2.7