<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Loubna Lekouaghet</title>
    <description>The latest articles on DEV Community by Loubna Lekouaghet (@loubna_lekouaghet_5b8028c).</description>
    <link>https://dev.to/loubna_lekouaghet_5b8028c</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3860899%2F92c1d9b7-ab52-42ac-b769-32ea115e982e.png</url>
      <title>DEV Community: Loubna Lekouaghet</title>
      <link>https://dev.to/loubna_lekouaghet_5b8028c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/loubna_lekouaghet_5b8028c"/>
    <language>en</language>
    <item>
      <title>Loops Explained: The Last Guide You'll Need as a Beginner</title>
      <dc:creator>Loubna Lekouaghet</dc:creator>
      <pubDate>Sat, 04 Apr 2026 11:38:43 +0000</pubDate>
      <link>https://dev.to/loubna_lekouaghet_5b8028c/loops-explained-the-last-guide-youll-need-as-a-beginner-1co8</link>
      <guid>https://dev.to/loubna_lekouaghet_5b8028c/loops-explained-the-last-guide-youll-need-as-a-beginner-1co8</guid>
      <description>&lt;p&gt;&lt;em&gt;This guide is written for complete beginners who are encountering loops for the first time.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As a beginner introduced to loops for the first time, you'll find them confusing at first. What is a loop? How should I use it? And is it necessary?.... You'll end up with a lot of questions but not an ideal solution, and this is the last explanation you need to know about loops.&lt;/p&gt;

&lt;p&gt;Loops are blocks of code that repeat automatically to execute the same expressions until a specified condition is met.&lt;/p&gt;

&lt;p&gt;If you want to execute a code a million times, you should use a loop instead of writing the code a million times. They save time, reduce errors, and make code much cleaner. &lt;/p&gt;

&lt;p&gt;You’ll find loops in almost every programming language you'll work with in the future ( such as JavaScript, TypeScript, Python, C#...). There are different types and different ways to implement a loop, but we can distinguish two major types:&lt;/p&gt;

&lt;p&gt;For loop: A for loop runs a specific number of times. Here is how to write a For loop using Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;variable&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;iterable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
    &lt;span class="c1"&gt;# Code to execute for each item
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While loop: A while loop keeps running until a condition is no longer true.  Here is how to write a While loop using Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Iteration: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Important: update the variable to eventually break the loop
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following examples show when you should use loops: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you try to find an item among a lot of items.&lt;/li&gt;
&lt;li&gt;When you try to compare different items. &lt;/li&gt;
&lt;li&gt;When you want to apply the same change to a lot of items.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Loops are one of the first tools that make you feel like a real programmer. Once you understand them, you'll see them everywhere — and wonder how you ever coded without them.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
