How to convert a list by mapping an element into multiple elements in python?
<p>For example,
how to convert [1, 5, 7] into [1,2,5,6,7,8] into python?
[x, x+1 for x in [1,5,7]] can't work for sure...</p>

<p>Make a generator function that iterates over the list and yields, in turn, each element and that element plus one.  Iterate over your generator.</p>

<pre><code>def foo(lyst):
    for element in lyst:
        yield element
        yield element + 1

&gt;&gt;&gt; print(list(foo([1, 5, 7])))
[1, 2, 5, 6, 7, 8]
&gt;&gt;&gt; 
&gt;&gt;&gt; print([element for element in foo([1, 5, 7])])
[1, 2, 5, 6, 7, 8]
&gt;&gt;&gt;
</code></pre>

python