Python: simple way to increment by alternating values?
<p>I am building a list of integers that should increment by 2 alternating values. </p>

<p>For example, starting at 0 and alternating between 4 and 2 up to 20 would make:</p>

<pre><code>[0,4,6,10,12,16,18]
</code></pre>

<p>range and xrange only accept a single integer for the increment value. What's the simplest way to do this? </p>

<p>1 Generate a range of numbers from 0 to n with step size 4
2 generate another range of numbers from 0 to n with step size 6
3 Combine both the list and sorted. Remove duplicates</p>

<pre><code>&gt;&gt;&gt; a = range(0,20,4)
&gt;&gt;&gt; a
[0, 4, 8, 12, 16]
&gt;&gt;&gt; b = range(0,20,6)
&gt;&gt;&gt; c = sorted(a + b)
&gt;&gt;&gt; b
[0, 6, 12, 18]
&gt;&gt;&gt; c
[0, 0, 4, 6, 8, 12, 12, 16, 18]
&gt;&gt;&gt; c = list(set(c))
&gt;&gt;&gt; c
[0, 4, 6, 8, 12, 16, 18]
</code></pre>

python increment