<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jared Steven on Medium]]></title>
        <description><![CDATA[Stories by Jared Steven on Medium]]></description>
        <link>https://medium.com/@jared21steven?source=rss-fa7dc12092f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Pq9_dNdw3279YaRgZmkznQ.png</url>
            <title>Stories by Jared Steven on Medium</title>
            <link>https://medium.com/@jared21steven?source=rss-fa7dc12092f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 22 May 2026 13:15:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jared21steven/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[For Loop: 3 Important Things To Know About It]]></title>
            <link>https://medium.com/@jared21steven/for-loop-3-important-things-to-know-about-it-5b3fb0d4acbc?source=rss-fa7dc12092f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b3fb0d4acbc</guid>
            <category><![CDATA[for-loop-in-python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Jared Steven]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 07:35:09 GMT</pubDate>
            <atom:updated>2024-06-30T13:41:30.150Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*J0emyOgf6nP3lBxFDYj3yA.png" /></figure><p>A <strong>For Loop</strong> is without a doubt the best looping statement to iterate through a sequence of ordered data, here you will read about the <strong>3 important things</strong> which make the for-loop more powerful in execution.</p><h3>What Is A For Loop?</h3><p>A <strong>for loop</strong> is used for iterating over a sequence of statements for each item in a list, tuple, set, etc.</p><pre>for friend in [&quot;Joe&quot;, &quot;Robin&quot;, &quot;Rajan&quot;, &quot;Balaji&quot;, &quot;Paris&quot;]: <br>    invite = &quot;Hi &quot; + friend + &quot;. Please come to my party!&quot; <br>    print(invite) </pre><pre>Output: <br><br>Hi Joe. Please come to my party! <br><br>Hi Robin. Please come to my party! <br><br>Hi Rajan. Please come to my party! <br><br>Hi Balaji. Please come to my party! <br><br>Hi Paris. Please come to my party!</pre><p>The variable friend in the for statement at line 1 is called the loop variable.</p><p>We could have chosen any other variable name instead, such as tomato: the computer or the compiler just doesn’t care. Lines 2 and 3 are the loop body.</p><p><strong>The loop’s body is always indented.</strong></p><p>The indentation determines precisely what statements are “in the body of the loop”.</p><p>On each iteration or pass of the loop, first, a check is done to see if there are still more items to be processed.</p><p>If there are none left <strong>(this is called the terminating condition of the loop)</strong>, the loop has finished.</p><p>Program execution continues at the following statement after the loop body, <strong>(e.g. in this case the following statement below the comment in line 4)</strong>.</p><p>If there are items still to be processed, the loop variable is updated to refer to the next item in the list.</p><p>This means, in this case, that the loop’s body is executed here 7 times, and each time friend will refer to a different friend.</p><p>At the end of each execution of the body of the for loop, Python returns to the for statement, to see if there are more items to be handled, and to assign the next one to a friend.</p><h3>Range() Function:</h3><p>To loop through a set of code a specified number of times, you can use the <strong><em>range() </em></strong>function, The <strong><em>range()</em></strong> function returns a sequence of numbers, starting from 0 by default, increments by 1 (by default), and ends at a specified number.</p><pre>for x in range(10): <br>    print(x) </pre><pre>Output: 0 1 2 3 4 5 6 7 8 9</pre><h3>Break Statement In For Loop:</h3><p>The <strong>break statement</strong> is used to stop the loop before it has looped through all the items.</p><pre># Exit the loop when x is &quot;Cherry&quot; <br><br>fruits = [&quot;Grapes&quot;, &quot;Apple&quot;, &quot;Cherry&quot;]<br>for x in fruits: <br>    print(x)<br>    if x == &quot;Cherry&quot;:<br>        break</pre><pre>Output: <br><br>Grapes Apple</pre><h3>Continue Statement In For Loop:</h3><p>The <strong><em>continue</em></strong> statement is used to stop the current iteration of the loop and continue with the next value.</p><pre>#Do not print Banana <br><br>fruits = [&quot;Apple&quot;, &quot;Banana&quot;, &quot;Cherry&quot;] <br><br>for x in fruits: if x == &quot;banana&quot;: <br>    continue print(x) </pre><pre>Output: Apple Cherry</pre><h3>About The Author</h3><p>I am <a href="https://www.linkedin.com/in/jaredsteven/"><strong>Jared Steven</strong></a>, with a unique combination of skills in the field of Data Science, AI Engineering, Technical Writing, Product Management and Web Development, I make it my business to help you make sense of technical concepts in my area of work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b3fb0d4acbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>