How else part work in continue statement?
<p>I'm not sure how the <code>continue</code> statement is interpreted when it is inside a <code>for</code> loop with an <code>else</code> clause.</p>

<p>If the condition is true, the <code>break</code> will exit from a <code>for</code> loop and <code>else</code> part will not be executed. And if the condition is False then <code>else</code> part will be executed. </p>

<p>But, what about <code>continue</code> statement? I tested it seems that the after the <code>continue</code> statement is reached, the <code>else</code> part will be executed. Is this true?? Here is a code example:</p>

<pre><code># when condition found and it's `true` then `else` part is executing :

edibles = ["ham", "spam", "eggs","nuts"]
for food in edibles:
    if food == "spam":
        print("No more spam please!")
        continue
    print("Great, delicious " + food)

else:
    print("I am so glad: No spam!")
print("Finally, I finished stuffing myself")`
</code></pre>

<p>If I remove "spam" from the list, now the condition is always <code>false</code> and never found but still the <code>else</code> part is executed:</p>

<pre><code>edibles = ["ham","eggs","nuts"]
for food in edibles:
    if food == "spam":
        print("No more spam please!")
        continue
    print("Great, delicious " + food)

else:
    print("I am so glad: No spam!")
print("Finally, I finished stuffing myself")
</code></pre>

<p>Your <code>else</code> part will be executed in both cases. 
<code>else</code> part executed when loop terminate when condition didn't found.Which is what is happening in your code. But it will also work same without <code>continue</code> statement.</p>

<p>now what about break statement's else part, Break statement's else part will be executed only if:</p>

<ul>
<li>If the loop completes normally without any break.</li>
<li>If the loop doesn't encounter a break.</li>
</ul>

<p><a href="http://i.stack.imgur.com/yPLeC.png" rel="nofollow"><img src="http://i.stack.imgur.com/yPLeC.png" alt="enter image description here"></a></p>

python for-loop for-else