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>You can do your list comprehension logic with tuples and then flatten the resulting list:</p>

<p><code>[n for pair in [(x, x+1) for x in [1,5,7]] for n in pair]</code></p>

python