<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Lowell Thornton</title>
        <link>https://paragraph.com/@lowell-thornton</link>
        <description>Python Developer</description>
        <lastBuildDate>Mon, 13 Apr 2026 23:46:29 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Lowell Thornton</title>
            <url>https://storage.googleapis.com/papyrus_images/c6187c80f2a4e2590edc059ce1b75118eb51ef2aa02c884b4c371fb8d82c3620.png</url>
            <link>https://paragraph.com/@lowell-thornton</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[“Else” condition inside a “for” loop]]></title>
            <link>https://paragraph.com/@lowell-thornton/else-condition-inside-a-for-loop</link>
            <guid>HuLk3LOvtlUbXBlEVY8W</guid>
            <pubDate>Thu, 30 Mar 2023 03:29:46 GMT</pubDate>
            <description><![CDATA[Despite all the Python code that you have seen so far, chances are that you may have missed the following “for-else” which I also got to see for the first time a couple of weeks ago. This is a “for-else” method of looping through a list, where despite having an iteration through a list, you also have an “else” condition, which is quite unusual. This is not something that I have seen in other programming languages like Java, Ruby, or JavaScript. Let’s see an example of how it looks in practice...]]></description>
            <content:encoded><![CDATA[<p>Despite all the Python code that you have seen so far, chances are that you may have missed the following “for-else” which I also got to see for the first time a couple of weeks ago.</p><p>This is a “for-else” method of looping through a list, where despite having an iteration through a list, you also have an “else” condition, which is quite unusual.</p><p>This is not something that I have seen in other programming languages like Java, Ruby, or JavaScript.</p><p>Let’s see an example of how it looks in practice.</p><p>Let’s say that we are trying to check whether there are no odd numbers in a list.</p><p>Let’s iterate through it:</p><pre data-type="codeBlock" text="numbers = [2, 4, 6, 8, 1]

for number in numbers:
    if number % 2 == 1:
        print(number)
        break
else:
    print(&quot;No odd numbers&quot;)
"><code>numbers <span class="hljs-operator">=</span> [<span class="hljs-number">2</span>, <span class="hljs-number">4</span>, <span class="hljs-number">6</span>, <span class="hljs-number">8</span>, <span class="hljs-number">1</span>]

<span class="hljs-keyword">for</span> number in numbers:
    <span class="hljs-keyword">if</span> number <span class="hljs-operator">%</span> <span class="hljs-number">2</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span>:
        print(number)
        <span class="hljs-keyword">break</span>
<span class="hljs-keyword">else</span>:
    print(<span class="hljs-string">"No odd numbers"</span>)
</code></pre><p>In case we find an odd number, then that number will be printed since <strong><em>break</em></strong> will be executed and the <strong><em>else</em></strong> branch will be skipped.</p><p>Otherwise, if <strong><em>break</em></strong> is never executed, the execution flow will continue with the <strong><em>else</em></strong> branch.</p><p>In this example, we are going to print 1.</p>]]></content:encoded>
            <author>lowell-thornton@newsletter.paragraph.com (Lowell Thornton)</author>
        </item>
    </channel>
</rss>