Python while loop does not work properly
<p>I am using a <code>while</code> loop inside a <code>if</code> / <code>else</code> condition. For some reason under one condition the while loop does not work. The condition is shown in my code below. Under these conditions I would assume that the <code>else</code> condition should be utilized and the <code>weight</code> and the <code>max_speed</code> should be decreased until both <code>while</code> conditions are not valid anymore. What am I doing wrong?</p>

<pre><code>weight = 0
max_speed = 15

if weight == 0 and max_speed &lt;= 10:
    while weight == 0 and max_speed &lt;= 10:
        weight=weight+1
        print(weight)
        print(max_speed)
else:
    while weight != 0 and max_speed &gt; 10:
        weight = weight-1
        max_speed=max_speed-1
        print(weight)
        print(max_speed)
</code></pre>

<p>Assuming that you need your <code>weight=0</code> and <code>max_speed=10</code>; You can do this ->    </p>

<pre><code>weight = 0
max_speed = 15

while weight !=0 or max_speed &gt; 10:
    if weight&gt;0: 
        weight = weight-1
    else:  
        weight = weight+1
    if max_speed&gt;10:
        max_speed=max_speed-1
    print("{} {}".format(weight, max_speed))
</code></pre>

<p>Your output looks like -></p>

<pre><code>1 14
0 13
1 12
0 11
1 10
0 10
</code></pre>

python if-statement while-loop