<?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 Saijadhav on Medium]]></title>
        <description><![CDATA[Stories by Saijadhav on Medium]]></description>
        <link>https://medium.com/@saijadhav527?source=rss-55fe79a059e7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*h16Kp8TPpJMFGrwg</url>
            <title>Stories by Saijadhav on Medium</title>
            <link>https://medium.com/@saijadhav527?source=rss-55fe79a059e7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:46:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saijadhav527/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[Understanding Loops and Conditional Statements in Python (A Beginner’s Guide)]]></title>
            <link>https://medium.com/@saijadhav527/understanding-loops-and-conditional-statements-in-python-a-beginners-guide-5c65276cc80b?source=rss-55fe79a059e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c65276cc80b</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Saijadhav]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 21:14:08 GMT</pubDate>
            <atom:updated>2026-08-31T21:17:20.155Z</atom:updated>
            <content:encoded><![CDATA[<p>If there are two concepts that unlock “real” programming in Python, they’re <strong>conditional statements</strong> and <strong>loops</strong>. Together, they let your code make decisions and repeat work — which is basically what every program does under the hood, whether it’s a to-do list app or a machine learning model.</p><p>In this post, we’ll break both down from scratch, with plenty of examples you can run yourself.</p><h4>1. Conditional Statements: Teaching Python to Make Decisions</h4><p>A conditional statement lets your program choose between different paths depending on whether something is True or False.</p><p><strong>The </strong><strong>if statement</strong></p><pre>age = 20<br><br>if age &gt;= 18:<br>    print(&quot;You are an adult.&quot;)</pre><p>Here, Python checks whether age &gt;= 18. If that condition is True, the indented block underneath runs. If it&#39;s False, Python just skips it.</p><p><strong>Adding </strong><strong>else</strong></p><p>What if you want something to happen when the condition is <em>not</em> met?</p><pre>age = 15<br><br>if age &gt;= 18:<br>    print(&quot;You are an adult.&quot;)<br>else:<br>    print(&quot;You are a minor.&quot;)</pre><p><strong>Adding </strong><strong>elif (else if)</strong></p><p>Real-world logic often has more than two outcomes. That’s where elif comes in:</p><pre>score = 72<br><br>if score &gt;= 90:<br>    print(&quot;Grade: A&quot;)<br>elif score &gt;= 75:<br>    print(&quot;Grade: B&quot;)<br>elif score &gt;= 60:<br>    print(&quot;Grade: C&quot;)<br>else:<br>    print(&quot;Grade: F&quot;)</pre><p>Python checks each condition <strong>top to bottom</strong> and runs the first block whose condition is True. It ignores the rest, even if they&#39;d also be true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yx8YUcOh1v537JX5D5mXVw.png" /></figure><p><strong>Comparison and logical operators you’ll use constantly</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KzDGEmP7bXd6huTdY_j2TQ.png" /></figure><h4><strong>2. Loops: Teaching Python to Repeat Itself</strong></h4><p>Loops let you run the same block of code multiple times without copy-pasting it. Python gives you two main tools: for and while.</p><p><strong>The </strong><strong>for loop</strong></p><p>Use a for loop when you know (or can generate) the sequence you want to iterate over — a list, a string, a range of numbers, etc.</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;]<br><br>for fruit in fruits:<br>    print(f&quot;I like {fruit}&quot;)</pre><p>Or with range(), which generates a sequence of numbers:</p><pre>for i in range(5):       # 0, 1, 2, 3, 4<br>    print(i)</pre><p><strong>The </strong><strong>while loop</strong></p><p>Use a while loop when you don&#39;t know in advance how many times you&#39;ll need to repeat — you just keep going <strong>while</strong> a condition holds true.</p><pre>count = 0<br><br>while count &lt; 5:<br>    print(f&quot;Count is {count}&quot;)<br>    count += 1</pre><p>Be careful: if the condition never becomes False, you get an <strong>infinite loop</strong>. Always make sure something inside the loop eventually changes the condition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wki9A-D5B7p8S4qfTvPvLQ.png" /></figure><p><strong>break and </strong><strong>continue</strong></p><ul><li><strong>break</strong> exits the loop immediately.</li><li><strong>continue</strong> skips the rest of the current iteration and moves to the next one</li></ul><pre>for number in range(1, 11):<br>    if number == 6:<br>        break            # stop the loop entirely<br>    print(number)</pre><pre>for number in range(1, 11):<br>    if number % 2 == 0:<br>        continue         # skip even numbers<br>    print(number)</pre><p><strong>Looping with </strong><strong>else</strong></p><p>Python’s loops support an else clause that runs only if the loop completes <strong>without</strong> hitting a break:</p><pre>for n in range(2, 10):<br>    if n % 7 == 0:<br>        print(&quot;Found a multiple of 7!&quot;)<br>        break<br>else:<br>    print(&quot;No multiples of 7 found.&quot;)</pre><h4>3. Putting It All Together</h4><p>Loops and conditionals are almost always used together. Here’s a small example that checks a list of numbers and labels each as even, odd, or a special “fizz” case:</p><pre>numbers = [3, 6, 7, 10, 15, 21]<br><br>for num in numbers:<br>    if num % 15 == 0:<br>        print(f&quot;{num}: Fizzbuzz!&quot;)<br>    elif num % 2 == 0:<br>        print(f&quot;{num}: Even&quot;)<br>    else:<br>        print(f&quot;{num}: Odd&quot;)</pre><p>This tiny snippet shows the core rhythm of most Python programs: <strong>loop through data, check conditions, act accordingly.</strong></p><h4>4. Common Beginner Mistakes to Avoid</h4><ul><li><strong>Forgetting the colon </strong><strong>:</strong> at the end of if, elif, else, for, and while statements.</li><li><strong>Inconsistent indentation</strong> — mixing tabs and spaces will cause errors.</li><li><strong>Using </strong><strong>= instead of </strong><strong>==</strong> — = assigns a value, == compares values.</li><li><strong>Writing infinite </strong><strong>while loops</strong> by forgetting to update the loop&#39;s condition variable.</li><li><strong>Overusing </strong><strong>elif chains</strong> when a dictionary lookup or match statement (Python 3.10+) might be cleaner.</li></ul><h4>5. Quick Recap</h4><ul><li><strong>Conditionals</strong> (if / elif / else) let your program branch based on True/False logic.</li><li><strong>for loops</strong> are ideal when iterating over a known sequence.</li><li><strong>while loops</strong> are ideal when repeating until a condition changes.</li><li><strong>break</strong> and <strong>continue</strong> give you fine control inside loops.</li><li>Combining conditionals and loops is how almost all real Python logic gets written.</li></ul><p>Once these two concepts feel natural, you’re ready to tackle functions, list comprehensions, and beyond — they all build on this same foundation.</p><p><em>Congrats — you just taught a computer to make decisions and repeat itself, which is more than some group chats can do. If this helped, clap and follow for more Python basics!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c65276cc80b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>