How is it possible to use a while loop to print even numbers 2 through 100?
<p>I am a beginner and I am stuck on this problem, "Write a python code that uses a while loop to print even numbers from 2 through 100. Hint ConsecutiveEven differ by 2."</p>

<p>Here is what I came up with so far: </p>

<pre><code> while num in range(22,101,2):
              print(num)
</code></pre>

<p>Use either <code>for</code> with <code>range()</code>, or use <code>while</code> and explicitly increment the number. For example:</p>

<pre><code>&gt;&gt;&gt; i = 2
&gt;&gt;&gt; while i &lt;=10: # Using while
...    print(i)
...    i += 2
...
2
4
6
8
10

&gt;&gt;&gt; for i in range(2, 11, 2): # Using for
...    print(i)
...
2
4
6
8
10
</code></pre>

python loops while-loop