<?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: Lavkush Kumar</title>
    <description>The latest articles on DEV Community by Lavkush Kumar (@kushkrg).</description>
    <link>https://dev.to/kushkrg</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1230268%2F61326777-e179-4941-a7f2-2be6372553e3.PNG</url>
      <title>DEV Community: Lavkush Kumar</title>
      <link>https://dev.to/kushkrg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kushkrg"/>
    <language>en</language>
    <item>
      <title>Bubble Sort Explained with Simple Python Examples</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Sun, 15 Nov 2026 05:36:15 +0000</pubDate>
      <link>https://dev.to/kushkrg/bubble-sort-explained-with-simple-python-examples-2525</link>
      <guid>https://dev.to/kushkrg/bubble-sort-explained-with-simple-python-examples-2525</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/bubble-sort-explained-with-examples" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Bubble sort is a simple sorting algorithm that compares neighbouring items again and again and swaps them whenever they are in the wrong order. After each full pass, the biggest unsorted value has bubbled up to its correct place at the end. In this guide you will dry run bubble sort on a small list, write the basic Python version, improve it with a swapped flag, count its comparisons and swaps, and see how it compares with Python's built in sorted(). Every output comes from running this article's code on Python 3.12.3.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Bubble Sort Works, in Plain Words
&lt;/h2&gt;

&lt;p&gt;Imagine students lined up by height, but shuffled. You walk along the line looking at each pair of neighbours. Whenever the taller student stands in front of the shorter one, they swap. By the end of the walk, the tallest student is at the back, having won every swap.&lt;/p&gt;

&lt;p&gt;That walk is called a pass. On the next pass, the second tallest ends up just before the tallest. Pass by pass, the sorted part grows at the end. The algorithm stops when a pass finishes with no swaps, which means everything is in order.&lt;/p&gt;

&lt;p&gt;Two details matter. Bubble sort only compares neighbours, never distant items. And equal values never swap, because we swap only when the left value is strictly greater. That makes it stable: equal items keep their original relative order.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Dry Run on a Small List, Pass by Pass
&lt;/h2&gt;

&lt;p&gt;Let us sort &lt;code&gt;[5, 2, 9, 1, 5, 6]&lt;/code&gt; by hand. In pass 1 we swap 5 and 2, keep 5 before 9, then swap 9 past 1, 5 and 6:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start: [5, 2, 9, 1, 5, 6]
End of pass 1: [2, 5, 1, 5, 6, 9]
End of pass 2: [2, 1, 5, 5, 6, 9]
End of pass 3: [1, 2, 5, 5, 6, 9]
End of pass 4: [1, 2, 5, 5, 6, 9]
Sorted: [1, 2, 5, 5, 6, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pass 2 pushes the 1 forward. Pass 3 swaps 2 and 1, and the list is sorted. Pass 4 changes nothing, and that quiet pass proves we can stop. After each pass, one more position at the end is final, so the unsorted part shrinks by one item every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Basic Bubble Sort in Python
&lt;/h2&gt;

&lt;p&gt;Here is the plain version. It copies the input first, so the caller's list is never changed:&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;def&lt;/span&gt; &lt;span class="nf"&gt;bubble_sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bubble_sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The outer loop runs the passes. The inner loop walks the still unsorted part, which is why its range is &lt;code&gt;n - 1 - i&lt;/code&gt;: after i passes, the last i items are sorted and need no more checks. The swap line exchanges two neighbours in one step, with no temporary variable. Python builds the right hand pair first, then unpacks it, so nothing is overwritten early.&lt;/p&gt;

&lt;p&gt;Adding two counters to the same code gave this real result on our test list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result: [1, 2, 5, 5, 6, 9]
Comparisons: 15
Swaps: 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fifteen comparisons for six items is no coincidence. The passes compare 5, then 4, then 3, then 2, then 1 pairs, which sums to 15. Double the list and the comparisons roughly quadruple. That is the whole complexity story in one sentence.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwrb7dmdtpt6nk6w0rwo3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwrb7dmdtpt6nk6w0rwo3.png" alt="Terminal window showing the real bubble sort run tested for this article: the list sorted pass by pass, 15 comparisons and 6 swaps, the optimised version stopping after one pass on a sorted list, and sorted() about 305 times faster on 1000 items"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A terminal window showing the real bubble sort run tested for this article: pass by pass states, comparison and swap counts, the early stop on sorted input, and the timing test against sorted().&lt;/p&gt;

&lt;h2&gt;
  
  
  The Optimised Version: Swapped Flag and Shrinking Range
&lt;/h2&gt;

&lt;p&gt;The basic version keeps passing even when the list became sorted early. The fix is a flag named &lt;code&gt;swapped&lt;/code&gt;: False at the start of each pass, True on any swap, and stop if a full pass ends with it still False. The shrinking range stays:&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;def&lt;/span&gt; &lt;span class="nf"&gt;bubble_sort_optimised&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;swapped&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="n"&gt;swapped&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;swapped&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this version on the already sorted list &lt;code&gt;[1, 2, 3, 4, 5, 6]&lt;/code&gt; gave:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;After pass 1: [1, 2, 3, 4, 5, 6] (swapped: False)
No swaps, so the list is sorted. Stop early.
Passes: 1
Comparisons: 5
Swaps: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One pass, five comparisons, done. On our shuffled test list the same code needed 4 passes and 14 comparisons, one fewer than the basic version, because it skipped the pointless final pass. A small win here, but a huge win on nearly sorted input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Time Complexity: Why Bubble Sort Is O(n^2)
&lt;/h2&gt;

&lt;p&gt;For n items, bubble sort makes about n passes of up to n comparisons, so the work grows with n squared: O(n^2) on average and in the worst case. The best case belongs to the optimised version on sorted input, where one pass of n comparisons proves the job is done: O(n). Extra memory is O(1), because sorting happens in place. If Big O itself feels fuzzy, our guide to &lt;a href="https://codingcush.com/big-o-notation-explained-simply" rel="noopener noreferrer"&gt;Big O notation explained simply, with everyday examples&lt;/a&gt; builds the idea from scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bubble Sort vs Python's sorted(): The Honest Comparison
&lt;/h2&gt;

&lt;p&gt;In real Python code you would rarely ship bubble sort, because &lt;code&gt;sorted()&lt;/code&gt; returns a new sorted list in one line:&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;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://docs.python.org/3/howto/sorting.html" rel="noopener noreferrer"&gt;official Python sorting guide&lt;/a&gt; explains that sorted() uses Timsort, which spots runs of already ordered data and merges them, making it fast and stable. The &lt;a href="https://docs.python.org/3/library/functions.html" rel="noopener noreferrer"&gt;built in functions documentation&lt;/a&gt; covers sorted() itself, including its key and reverse options. We timed both on the same 1,000 random numbers (seed 42):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List size: 1000
Optimised bubble sort: 0.0548 seconds
Built-in sorted():     0.000180 seconds
sorted() was about 305 times faster in this run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exact timings vary by machine, but the gap widens as lists grow, because O(n log n) pulls away from O(n^2) quickly.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Case or feature&lt;/th&gt;
&lt;th&gt;Bubble sort&lt;/th&gt;
&lt;th&gt;Python sorted() (Timsort)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Best case&lt;/td&gt;
&lt;td&gt;O(n), optimised, on sorted input&lt;/td&gt;
&lt;td&gt;O(n) on ordered data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average case&lt;/td&gt;
&lt;td&gt;O(n^2)&lt;/td&gt;
&lt;td&gt;O(n log n)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Worst case&lt;/td&gt;
&lt;td&gt;O(n^2)&lt;/td&gt;
&lt;td&gt;O(n log n)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extra memory&lt;/td&gt;
&lt;td&gt;O(1), in place&lt;/td&gt;
&lt;td&gt;O(n) worst case&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best use&lt;/td&gt;
&lt;td&gt;Learning, tiny lists&lt;/td&gt;
&lt;td&gt;Real code, any size&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  When Bubble Sort Is and Is Not Useful
&lt;/h2&gt;

&lt;p&gt;Bubble sort is useful for learning how sorting, loops and complexity fit together, for interviews about swaps, and for tiny, nearly sorted lists, where the optimised version finishes in a pass or two.&lt;/p&gt;

&lt;p&gt;It is not useful for large data or production Python code. If your list has thousands of items and you wrote two nested loops, the honest fix is not a cleverer bubble sort. It is sorted(). The neighbour thinking still pays off elsewhere, for example when you compare a &lt;a href="https://codingcush.com/stack-vs-queue-difference" rel="noopener noreferrer"&gt;stack vs a queue and how each one orders its items&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Off by one in the inner range.&lt;/strong&gt; Writing &lt;code&gt;range(n - i)&lt;/code&gt; instead of &lt;code&gt;range(n - 1 - i)&lt;/code&gt; lets j reach the last index, and &lt;code&gt;a[j + 1]&lt;/code&gt; raises IndexError: list index out of range. The minus 1 exists because the loop looks one step ahead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resetting the swapped flag in the wrong place.&lt;/strong&gt; If &lt;code&gt;swapped = False&lt;/code&gt; sits inside the inner loop, the flag forgets earlier swaps and the sort can stop early. The reset belongs at the start of each pass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sorting the caller's list by accident.&lt;/strong&gt; If the caller still needs the original order, copy first with &lt;code&gt;numbers[:]&lt;/code&gt;, or use sorted(), which returns a new list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why is it called bubble sort?
&lt;/h3&gt;

&lt;p&gt;Because the largest unsorted value rises to the end on every pass, the way a bubble rises through water.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is bubble sort stable?
&lt;/h3&gt;

&lt;p&gt;Yes, in the form shown here. We swap only when the left value is strictly greater, so equal items never change their relative order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I use bubble sort in real Python projects?
&lt;/h3&gt;

&lt;p&gt;Almost never. Use sorted() or the list sort() method: faster, tested and shorter. Bubble sort earns its place in learning and interviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should I learn after bubble sort?
&lt;/h3&gt;

&lt;p&gt;Selection sort and insertion sort come next, then merge sort. After that, &lt;a href="https://codingcush.com/recursion-explained-with-examples" rel="noopener noreferrer"&gt;recursion explained with simple Python examples&lt;/a&gt; unlocks the divide and conquer sorts, built on a function that calls itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Bubble sort does one humble thing well: it teaches you to watch an algorithm work. You saw [5, 2, 9, 1, 5, 6] settle into order, counted its 15 comparisons and 6 swaps, watched the optimised version quit after one pass on sorted input, and measured sorted() finishing about 305 times faster on 1,000 items. Learn it for the thinking, then sort real lists the Python way.&lt;/p&gt;

</description>
      <category>python</category>
      <category>algorithms</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>CSS Grid Explained with Simple Examples</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Sun, 15 Nov 2026 05:35:20 +0000</pubDate>
      <link>https://dev.to/kushkrg/css-grid-explained-with-simple-examples-39jb</link>
      <guid>https://dev.to/kushkrg/css-grid-explained-with-simple-examples-39jb</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/css-grid-explained-with-examples" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;CSS Grid is a layout system built into CSS that lets you place items in rows and columns at the same time. You turn a parent element into a grid container with &lt;code&gt;display: grid&lt;/code&gt;, define the columns and rows, add spacing with &lt;code&gt;gap&lt;/code&gt;, and the browser lines everything up for you. In this guide you will learn the core ideas step by step, build a complete card gallery you can copy, and see when Grid beats Flexbox.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Grid Container?
&lt;/h2&gt;

&lt;p&gt;Every grid starts with a container. Pick the element that wraps your items, a &lt;code&gt;div&lt;/code&gt;, a &lt;code&gt;section&lt;/code&gt; or a &lt;code&gt;main&lt;/code&gt; element, and set &lt;code&gt;display: grid&lt;/code&gt; on it. That one line changes how its direct children behave. The children become grid items, and the container controls where they sit.&lt;/p&gt;

&lt;p&gt;Think of it like a spreadsheet. Columns run down, rows run across, and each item sits in a cell where a row and a column meet. Lines are the borders between cells, and tracks are the rows and columns themselves. You describe the spreadsheet, and the browser builds it.&lt;/p&gt;

&lt;p&gt;If you are still sorting out which language does what on a page, our guide to &lt;a href="https://codingcush.com/html-vs-css-vs-javascript-difference" rel="noopener noreferrer"&gt;the difference between HTML, CSS and JavaScript&lt;/a&gt; is a friendly place to start. HTML gives the structure, CSS, including Grid, gives the layout.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Basic_concepts_of_grid_layout" rel="noopener noreferrer"&gt;MDN guide to the basic concepts of grid layout&lt;/a&gt; explains containers, items, lines and tracks in detail, and it is worth bookmarking as you practise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create Your First Grid
&lt;/h2&gt;

&lt;p&gt;Start with simple HTML and one CSS rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="box"&amp;gt;
  &amp;lt;div&amp;gt;One&amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;Two&amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;Three&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

.box {
  display: grid;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a real grid already. With no columns defined, Grid creates one column and stacks the three items in three rows. The magic starts when you describe the columns and rows yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Define Columns and Rows
&lt;/h2&gt;

&lt;p&gt;Two properties do most of the work. &lt;code&gt;grid-template-columns&lt;/code&gt; sets how many columns there are and how wide each one is. &lt;code&gt;grid-template-rows&lt;/code&gt; does the same job for rows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
  display: grid;
  grid-template-columns: 200px 200px 200px;
  grid-template-rows: 100px 100px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This says: make three columns, each 200 pixels wide, and two rows, each 100 pixels tall. Six items fill it perfectly. A seventh item creates a new row automatically, which is handy and also a common surprise.&lt;/p&gt;

&lt;p&gt;Fixed sizes are clear, but they do not adapt to different screens. That is why Grid has a unit made just for this job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Meet the fr Unit
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;fr&lt;/code&gt; unit means one fraction of the free space. It is Grid only, and it makes columns share space fairly without any maths from you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-columns: 1fr 1fr 1fr;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the free space is split into three equal parts. Change it to &lt;code&gt;2fr 1fr&lt;/code&gt; and the first column gets twice the share of the second. It is like slicing a cake where one guest politely, and correctly, gets a bigger slice.&lt;/p&gt;

&lt;p&gt;Writing the same value again and again gets dull, so use &lt;code&gt;repeat()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-columns: repeat(3, 1fr);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That line means the same as &lt;code&gt;1fr 1fr 1fr&lt;/code&gt;, but it is shorter and easier to change. The full &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout" rel="noopener noreferrer"&gt;MDN CSS grid layout reference&lt;/a&gt; lists every Grid property you will meet as you grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Add Space with gap
&lt;/h2&gt;

&lt;p&gt;Items that touch each other look cramped. The &lt;code&gt;gap&lt;/code&gt; property adds space between rows and columns, and only between them, never around the outside edge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One value sets both gaps. Two values set them separately: &lt;code&gt;gap: 24px 16px&lt;/code&gt; means 24 pixels between rows and 16 between columns. Before &lt;code&gt;gap&lt;/code&gt;, developers used margins and fixed the extra edge space by hand. Grid skips that headache.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxkozhu9tro47jiwgdhbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxkozhu9tro47jiwgdhbg.png" alt="Terminal style code listing showing the verified CSS Grid gallery rules, the Python check confirming balanced braces and all Grid properties present, and the layout measurements for a 900 pixel container" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Terminal style code listing for this article: the gallery CSS rules, the verified check on the test file, and the layout measurements for a 900 pixel container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Place Items with grid-column
&lt;/h2&gt;

&lt;p&gt;By default, each item takes one cell and they flow in order. Sometimes one item deserves more room, like a featured card at the top of a gallery. Use &lt;code&gt;grid-column&lt;/code&gt; on that item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.featured {
  grid-column: span 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;span 2&lt;/code&gt; means this item stretches across two columns. You can also name exact lines: &lt;code&gt;grid-column: 1 / 3&lt;/code&gt; means start at line 1 and end at line 3, the same width. Beginners usually find &lt;code&gt;span&lt;/code&gt; easier, so start there. The row version is &lt;code&gt;grid-row&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Good structure helps Grid too. Using meaningful elements for your sections and cards, as covered in our guide to &lt;a href="https://codingcush.com/html-semantic-tags-explained" rel="noopener noreferrer"&gt;HTML semantic tags explained with examples&lt;/a&gt;, keeps your markup clear while Grid handles the visual placement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: A Complete Card Gallery You Can Copy
&lt;/h2&gt;

&lt;p&gt;Now put it all together. This is the exact example tested for this article. It builds a gallery with a wide featured card and four normal cards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="gallery"&amp;gt;
  &amp;lt;article class="card featured"&amp;gt;
    &amp;lt;h2&amp;gt;Featured&amp;lt;/h2&amp;gt;&amp;lt;p&amp;gt;Wide card.&amp;lt;/p&amp;gt;
  &amp;lt;/article&amp;gt;
  &amp;lt;article class="card"&amp;gt;&amp;lt;h2&amp;gt;Card 2&amp;lt;/h2&amp;gt;&amp;lt;p&amp;gt;Normal card.&amp;lt;/p&amp;gt;&amp;lt;/article&amp;gt;
  &amp;lt;article class="card"&amp;gt;&amp;lt;h2&amp;gt;Card 3&amp;lt;/h2&amp;gt;&amp;lt;p&amp;gt;Normal card.&amp;lt;/p&amp;gt;&amp;lt;/article&amp;gt;
  &amp;lt;article class="card"&amp;gt;&amp;lt;h2&amp;gt;Card 4&amp;lt;/h2&amp;gt;&amp;lt;p&amp;gt;Normal card.&amp;lt;/p&amp;gt;&amp;lt;/article&amp;gt;
  &amp;lt;article class="card"&amp;gt;&amp;lt;h2&amp;gt;Card 5&amp;lt;/h2&amp;gt;&amp;lt;p&amp;gt;Normal card.&amp;lt;/p&amp;gt;&amp;lt;/article&amp;gt;
&amp;lt;/div&amp;gt;

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}
.card {
  background: #eef6ff;
  padding: 20px;
  border-radius: 8px;
}
.featured {
  grid-column: span 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what happens. The gallery has three equal columns. In a 900 pixel container, each column is 289.33 pixels wide, because the two 16 pixel gaps use 32 pixels first: (900 minus 32) divided by 3. The featured card spans two columns, so it is 594.67 pixels wide. Row one holds the featured card and Card 2. Row two holds Cards 3, 4 and 5. No floats and no extra wrapper divs.&lt;/p&gt;

&lt;p&gt;We verified this example in a standalone HTML file: the CSS braces were balanced, all the Grid properties were present, and the five article elements were correctly opened and closed. Try changing &lt;code&gt;repeat(3, 1fr)&lt;/code&gt; to &lt;code&gt;repeat(2, 1fr)&lt;/code&gt; and watch the gallery rebuild into two columns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Grid vs Flexbox: Which One Should You Use?
&lt;/h2&gt;

&lt;p&gt;Grid and Flexbox are friends, not rivals. Flexbox lays items out in one direction, a row or a column. Grid works in two directions at once. If you know the shape of the whole page, Grid usually wins. For a line of items that should wrap and centre, Flexbox is often simpler. Our companion guide to &lt;a href="https://codingcush.com/css-flexbox-explained-with-examples" rel="noopener noreferrer"&gt;CSS Flexbox explained with simple examples&lt;/a&gt; covers that case in the same style.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;CSS Grid&lt;/th&gt;
&lt;th&gt;Flexbox&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Main job&lt;/td&gt;
&lt;td&gt;Page layouts in rows and columns&lt;/td&gt;
&lt;td&gt;Items in a single row or column&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Directions&lt;/td&gt;
&lt;td&gt;Two: rows and columns together&lt;/td&gt;
&lt;td&gt;One at a time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Galleries, dashboards, whole pages&lt;/td&gt;
&lt;td&gt;Menus, toolbars, centring items&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Item placement&lt;/td&gt;
&lt;td&gt;You can place items in exact cells&lt;/td&gt;
&lt;td&gt;Items flow and size by content&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical start&lt;/td&gt;
&lt;td&gt;&lt;code&gt;grid-template-columns&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;justify-content&lt;/code&gt; and &lt;code&gt;align-items&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A common pattern is Grid for the page and Flexbox inside each card.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Putting display: grid on the wrong element.&lt;/strong&gt; Grid only controls direct children. If your cards are wrapped in extra divs, the wrapper becomes the item, not the card. Check your HTML nesting first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expecting gap around the outside.&lt;/strong&gt; &lt;code&gt;gap&lt;/code&gt; adds space only between tracks. If you want space around the whole grid, add &lt;code&gt;padding&lt;/code&gt; to the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confusing columns and rows.&lt;/strong&gt; &lt;code&gt;grid-template-columns&lt;/code&gt; controls widths as you read across. If your layout looks rotated, you probably swapped the two template properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fixed sizes that overflow small screens.&lt;/strong&gt; Three 200 pixel columns need at least 600 pixels plus gaps. On a phone that overflows. Prefer &lt;code&gt;fr&lt;/code&gt; units for flexible columns, and test at a narrow width.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forgetting that extra items create new rows.&lt;/strong&gt; Grid adds rows for items you did not plan for. Check your item count when a layout looks taller than expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is CSS Grid hard for beginners?
&lt;/h3&gt;

&lt;p&gt;No. Start with &lt;code&gt;display: grid&lt;/code&gt;, &lt;code&gt;grid-template-columns&lt;/code&gt; and &lt;code&gt;gap&lt;/code&gt;. Those three alone build most beginner layouts, and the rest can wait.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does 1fr mean in Grid?
&lt;/h3&gt;

&lt;p&gt;It means one fraction of the free space left after fixed sizes and gaps are taken away. Three columns of &lt;code&gt;1fr&lt;/code&gt; share that space equally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I learn Grid or Flexbox first?
&lt;/h3&gt;

&lt;p&gt;Learn Flexbox basics first if you mainly centre items and build menus, then learn Grid for full page layouts. In practice you will use both together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Grid work in all modern browsers?
&lt;/h3&gt;

&lt;p&gt;Yes. Grid is supported in all modern browsers, including Chrome, Firefox, Safari and Edge, so the examples in this article are safe to use today.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I make a grid item span two rows?
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;grid-row: span 2&lt;/code&gt; on that item, in the same way &lt;code&gt;grid-column: span 2&lt;/code&gt; spans two columns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Grid stops being scary once you see it as a described spreadsheet: a container, columns and rows you define, &lt;code&gt;fr&lt;/code&gt; units that share space fairly, &lt;code&gt;gap&lt;/code&gt; for breathing room, and &lt;code&gt;grid-column&lt;/code&gt; when one item needs more space. Copy the gallery, change the numbers, and break it on purpose.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Top 10 Fastest-Growing Claude Skill Repos (September 2026)</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Sun, 15 Nov 2026 03:39:12 +0000</pubDate>
      <link>https://dev.to/kushkrg/top-10-fastest-growing-claude-skill-repos-september-2026-nl8</link>
      <guid>https://dev.to/kushkrg/top-10-fastest-growing-claude-skill-repos-september-2026-nl8</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/top-10-fastest-growing-claude-skill-repos" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Claude Skills are small instruction packs that teach an AI coding agent a new trick, and in September 2026 developers starred them at a wild pace. The fastest-growing skill repo of the month, Ponytail, gained 30,432 GitHub stars in 30 days. This article ranks the top 10 fastest-growing Claude skill repos of September 2026 by stars gained, using the data tracked by &lt;a href="https://skillleaderboard.com" rel="noopener noreferrer"&gt;Skill Leaderboard&lt;/a&gt;, and explains what each skill actually does in plain words.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Claude Skill, in 30 Seconds?
&lt;/h2&gt;

&lt;p&gt;A skill is a folder with a SKILL.md file inside it. That file holds instructions, examples and sometimes small scripts. When you give a skill to a coding agent, the agent reads those instructions and follows them whenever the matching task shows up. Think of it as a reusable recipe card: instead of explaining the same preference to your AI every day, you write it once and the agent remembers.&lt;/p&gt;

&lt;p&gt;Skills are the layer above the model itself. If you are new to the agent side, first read our explainer on &lt;a href="https://codingcush.com/what-is-claude-ai-explained" rel="noopener noreferrer"&gt;what Claude AI is and what it can do&lt;/a&gt;. Anthropic also keeps its own public collection in the &lt;a href="https://github.com/anthropics/skills" rel="noopener noreferrer"&gt;anthropics/skills repository&lt;/a&gt;, which is a good place to see the format up close.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Top 10, Ranked by Stars Gained in September 2026
&lt;/h2&gt;

&lt;p&gt;Every figure below is the number of GitHub stars the repo gained between 1 and 30 September 2026, as reported by Skill Leaderboard. The total stars column shows roughly where each repo stands now, in mid November 2026, so you can see which ones kept growing after September ended.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Skill&lt;/th&gt;
&lt;th&gt;Repo&lt;/th&gt;
&lt;th&gt;Stars gained (Sept 2026)&lt;/th&gt;
&lt;th&gt;Total stars (approx.)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Ponytail&lt;/td&gt;
&lt;td&gt;DietrichGebert/ponytail&lt;/td&gt;
&lt;td&gt;+30,432&lt;/td&gt;
&lt;td&gt;191k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Matt Pocock Skills&lt;/td&gt;
&lt;td&gt;mattpocock/skills&lt;/td&gt;
&lt;td&gt;+29,787&lt;/td&gt;
&lt;td&gt;324k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;I Have ADHD&lt;/td&gt;
&lt;td&gt;ayghri/i-have-adhd&lt;/td&gt;
&lt;td&gt;+26,258&lt;/td&gt;
&lt;td&gt;61k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Security Audit Skill&lt;/td&gt;
&lt;td&gt;cloudflare/security-audit-skill&lt;/td&gt;
&lt;td&gt;+20,148&lt;/td&gt;
&lt;td&gt;72k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Superpowers&lt;/td&gt;
&lt;td&gt;obra/superpowers&lt;/td&gt;
&lt;td&gt;+13,841&lt;/td&gt;
&lt;td&gt;317k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Diagram Design&lt;/td&gt;
&lt;td&gt;cathrynlavery/diagram-design&lt;/td&gt;
&lt;td&gt;+13,795&lt;/td&gt;
&lt;td&gt;67k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Humanizer&lt;/td&gt;
&lt;td&gt;blader/humanizer&lt;/td&gt;
&lt;td&gt;+13,769&lt;/td&gt;
&lt;td&gt;69k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Graphify&lt;/td&gt;
&lt;td&gt;Graphify-Labs/graphify&lt;/td&gt;
&lt;td&gt;+9,651&lt;/td&gt;
&lt;td&gt;147k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;Addy Osmani Skills&lt;/td&gt;
&lt;td&gt;addyosmani/agent-skills&lt;/td&gt;
&lt;td&gt;+8,880&lt;/td&gt;
&lt;td&gt;117k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Impeccable&lt;/td&gt;
&lt;td&gt;pbakaus/impeccable&lt;/td&gt;
&lt;td&gt;+8,505&lt;/td&gt;
&lt;td&gt;110k&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzdqvwpjn481k4gmspmng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzdqvwpjn481k4gmspmng.png" alt="The Skill Leaderboard homepage at skillleaderboard.com, data through 14 November 2026, ranking agent skill repositories by GitHub stars" width="799" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Skill Leaderboard homepage (skillleaderboard.com), data through 14 November 2026. It tracks agent skill repos from open GitHub repositories, and its live table still shows mattpocock/skills and obra/superpowers at the top.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Ponytail (DietrichGebert/ponytail): +30,432 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/DietrichGebert/ponytail" rel="noopener noreferrer"&gt;Ponytail&lt;/a&gt; finished September at number one, and its idea is funny because it is true: the repo says it makes your AI agent think like the laziest senior developer in the room, because the best code is the code you never wrote. The skill pushes the agent to reuse what already exists, keep solutions small, and audit repo quality instead of adding more and more code. Developers clearly loved the honesty. It also tracks technical debt, so the laziness stays smart, not sloppy.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Matt Pocock Skills (mattpocock/skills): +29,787 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/mattpocock/skills" rel="noopener noreferrer"&gt;Matt Pocock's skills repo&lt;/a&gt; is exactly what its description promises: skills for real engineers, taken straight from the author's own agent setup. The focus is designing codebases well and reviewing implementations properly, the daily work of a senior developer. Pocock is a well-known TypeScript educator, so thousands of developers trust his taste. The repo is now the biggest on the whole leaderboard, at roughly 324k stars.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. I Have ADHD (ayghri/i-have-adhd): +26,258 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/ayghri/i-have-adhd" rel="noopener noreferrer"&gt;I Have ADHD&lt;/a&gt; is the surprise hit of the list. The skill makes agent responses concise, structured and action-first, so answers are easy to scan and easy to act on, with the important step never buried in the middle. You do not need ADHD to benefit; anyone who has scrolled through a wall of AI text looking for the one useful line will understand why this repo exploded.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Security Audit Skill (cloudflare/security-audit-skill): +20,148 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/cloudflare/security-audit-skill" rel="noopener noreferrer"&gt;Cloudflare's Security Audit Skill&lt;/a&gt; audits codebases and APIs for vulnerabilities. Two things made it grow fast: security is the one area where nobody wants to guess, and the author is Cloudflare, a company the whole internet already trusts with security. An official skill from a big name carries weight that a random repo cannot match.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Superpowers (obra/superpowers): +13,841 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/obra/superpowers" rel="noopener noreferrer"&gt;Superpowers&lt;/a&gt; describes itself as an agentic skills framework and software development methodology that works. Instead of one small trick, it teaches the agent how to plan engineering work and coordinate parallel agents on bigger tasks. At roughly 317k total stars, it is one of the giants of this list.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Diagram Design (cathrynlavery/diagram-design): +13,795 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/cathrynlavery/diagram-design" rel="noopener noreferrer"&gt;Diagram Design&lt;/a&gt; draws branded diagrams in HTML and SVG. Every developer has suffered through ugly architecture diagrams made in a hurry; this skill produces clean, good-looking ones from your agent instead. It is a narrow skill, but it solves a pain everyone recognises.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Humanizer (blader/humanizer): +13,769 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/blader/humanizer" rel="noopener noreferrer"&gt;Humanizer&lt;/a&gt; edits AI-written text and removes the signs of AI-generated writing, turning stiff output into natural prose. Writers, students and content teams all feel this problem daily, so a skill that polishes text in one step was always going to travel fast. Its growth also says something honest about 2026: we all use AI to write, and we all want the result to sound human.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Graphify (Graphify-Labs/graphify): +9,651 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/Graphify-Labs/graphify" rel="noopener noreferrer"&gt;Graphify&lt;/a&gt; turns a whole codebase, together with its docs, SQL schemas, configs and PDFs, into a queryable knowledge graph. On a big project, the hardest question is usually where things live and how they connect, and a map the agent can query is a serious upgrade.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Addy Osmani Skills (addyosmani/agent-skills): +8,880 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/addyosmani/agent-skills" rel="noopener noreferrer"&gt;Addy Osmani's agent skills&lt;/a&gt; teach a disciplined loop: specify, build, verify and ship software incrementally. Osmani is a long-time Chrome engineer whose books and talks shaped a generation of web developers, so his personal workflow, packaged as skills, was always going to attract attention. This is the slow and steady entry on the list, and probably one of the most useful.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Impeccable (pbakaus/impeccable): +8,505 stars
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/pbakaus/impeccable" rel="noopener noreferrer"&gt;Impeccable&lt;/a&gt; audits UX and refines frontend design, which makes it the designer's answer to the security audit skill. It comes from Paul Bakaus, another respected name in web tooling. Agents can write frontend code quickly, but taste is rarer; a skill that reviews the result like a design critic fills a real gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  What This List Tells Us
&lt;/h2&gt;

&lt;p&gt;Three patterns stand out. First, the top of the list is about discipline, not magic: write less code (Ponytail), answer clearly (I Have ADHD), work like a senior engineer (Pocock, Osmani). Second, famous names matter: Pocock, Osmani, Bakaus and Cloudflare all brought an audience with them. Third, review skills are hot: security audits, UX audits and code review all appear, because generating code is now easy and checking it is the bottleneck. If you are new to GitHub itself, our guide on &lt;a href="https://codingcush.com/github-what-is-github-why-its-important" rel="noopener noreferrer"&gt;what GitHub is and why it matters&lt;/a&gt; explains stars, repos and forks in simple words.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Try a Skill Safely (and Mistakes to Avoid)
&lt;/h2&gt;

&lt;p&gt;Start with one skill, not ten. Read its SKILL.md file first; it is plain text, and you should understand what the agent will do before you install anything. Add the skill, run it on a small test project, and watch whether the output actually improves. Only then keep it in your daily setup. If you already use an AI pair programmer, our walkthrough on &lt;a href="https://codingcush.com/how-to-use-github-copilot-in-vs-code" rel="noopener noreferrer"&gt;using GitHub Copilot in VS Code&lt;/a&gt; shows the same careful, one-step-at-a-time approach.&lt;/p&gt;

&lt;p&gt;The common mistakes are easy to guess. Installing every trending skill at once, so they fight each other. Skipping the SKILL.md and trusting the repo name alone. And treating stars as a quality guarantee: stars measure attention, not testing. A small repo you have read fully is safer than a famous one you have not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Which Claude skill repo grew the fastest in September 2026?
&lt;/h3&gt;

&lt;p&gt;Ponytail (DietrichGebert/ponytail), with 30,432 GitHub stars gained between 1 and 30 September 2026, as tracked by Skill Leaderboard. Matt Pocock Skills was a close second with 29,787.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Claude Skill?
&lt;/h3&gt;

&lt;p&gt;A skill is a reusable pack of instructions, usually centred on a SKILL.md file, that teaches an AI agent how to handle a type of task in a specific way. You install it once, and the agent follows it whenever the task matches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are these skill repos free?
&lt;/h3&gt;

&lt;p&gt;The repos on this list are public on GitHub, so you can read and download them freely. Each repo has its own licence, so check that file if you plan to use a skill in commercial work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do these skills only work with Claude?
&lt;/h3&gt;

&lt;p&gt;Not always. The SKILL.md format is open, and Skill Leaderboard tracks agent skills generally, so many of these repos also work with other coding agents. Check the README of the repo you like for the agents it supports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;September 2026 was the month Claude Skills went mainstream: a joke-named repo about writing less code beat everyone, a formatting skill for clearer answers took third place, and Cloudflare showed that big companies now publish skills too. Pick one repo from this list, read it properly, and try it on a small project this week. That is how the star counts on next month's leaderboard get decided.&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>github</category>
      <category>agents</category>
    </item>
    <item>
      <title>What Is pip? Install and Manage Python Packages</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:50:58 +0000</pubDate>
      <link>https://dev.to/kushkrg/what-is-pip-install-and-manage-python-packages-31dl</link>
      <guid>https://dev.to/kushkrg/what-is-pip-install-and-manage-python-packages-31dl</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/what-is-pip-python-package-manager" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;pip is the standard package installer for Python. When a tutorial says "just pip install it", pip is the tool that downloads a ready made library and places it where your Python can use it. In this guide you will learn what pip and PyPI are, how to check whether you already have pip, and how to use install, list, show, freeze, upgrade and uninstall. Every command was tested in a real virtual environment on Python 3.12.3 with pip 24.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are pip and PyPI in Plain Words?
&lt;/h2&gt;

&lt;p&gt;Think of Python as a phone with good built in apps. Sooner or later you want a new one. pip is the assistant that fetches it and installs it in the right place. The store itself is PyPI, short for the Python Package Index, where developers publish packages anyone can install with one command.&lt;/p&gt;

&lt;p&gt;You name a package, pip talks to PyPI, downloads it and anything it depends on, and installs it into your current environment. Seconds later you can import it. The &lt;a href="https://pip.pypa.io/en/stable/" rel="noopener noreferrer"&gt;official pip documentation&lt;/a&gt; covers every option pip offers, but daily work needs only a handful of commands, and this article covers those.&lt;/p&gt;

&lt;p&gt;Good news: you probably already have pip. It has shipped with standard Python installers since Python 3.4, via ensurepip.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Check That pip Is Already Installed
&lt;/h2&gt;

&lt;p&gt;Open a terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Mac and Linux, use &lt;code&gt;python3 -m pip --version&lt;/code&gt; if plain &lt;code&gt;python&lt;/code&gt; is not available. In our test on Python 3.12.3 the answer was (your folder path will differ):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip 24.0 from /project/.venv/lib/python3.12/site-packages/pip (python 3.12)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That line gives the pip version (24.0), its folder, and its Python (3.12). If you see a line like this, pip is ready. If you see an error, jump to troubleshooting below.&lt;/p&gt;

&lt;p&gt;Note the shape: &lt;code&gt;python -m pip&lt;/code&gt;, not just &lt;code&gt;pip&lt;/code&gt;. The &lt;code&gt;-m&lt;/code&gt; flag runs the pip module belonging to that exact Python. Many computers hold more than one Python, and bare &lt;code&gt;pip&lt;/code&gt; may belong to a different one, which causes the classic bug where the install "worked" but the import fails. If Python itself is missing, follow our guide to &lt;a href="https://codingcush.com/how-to-install-python-on-windows-vs-code" rel="noopener noreferrer"&gt;how to install Python on Windows and set up VS Code&lt;/a&gt; first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Install Your First Package
&lt;/h2&gt;

&lt;p&gt;Let us install something small and safe: &lt;code&gt;cowsay&lt;/code&gt;, which draws a cow saying whatever you type. In an active environment, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip install cowsay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the real output from our test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Collecting cowsay
Installing collected packages: cowsay
Successfully installed cowsay-6.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pip found cowsay on PyPI, downloaded its wheel file (a prebuilt package format), and installed version 6.1. Now prove it works:&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;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="s2"&gt;"import cowsay; cowsay.cow('Hello from pip!')"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python prints a cheerful cow with your message in a speech bubble. You just completed the full loop every real project uses: name a package, let pip fetch it, import it, run it. Real packages such as requests install in exactly the same way. You can also pin an exact version, for example &lt;code&gt;python -m pip install "cowsay==6.1"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6rfeue35u54508wj6ori.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6rfeue35u54508wj6ori.png" alt="Terminal window showing the real pip session tested for this article: pip 24.0 reporting its version, cowsay 6.1 installing successfully, and pip list showing cowsay and pip inside a virtual environment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The real pip session tested for this article: pip 24.0, cowsay 6.1 installed, and pip list inside a virtual environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: See What You Have with list, show and freeze
&lt;/h2&gt;

&lt;p&gt;Installing is only half the job. You also need to inspect what an environment holds. Three commands cover this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;List everything.&lt;/strong&gt; &lt;code&gt;python -m pip list&lt;/code&gt; shows every installed package and its version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Package Version
------- -------
cowsay  6.1
pip     24.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show one package.&lt;/strong&gt; &lt;code&gt;python -m pip show cowsay&lt;/code&gt; prints the name, version, summary and the exact folder it lives in. That Location line proves which environment it went into.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Freeze the list.&lt;/strong&gt; &lt;code&gt;python -m pip freeze&lt;/code&gt; prints each project package as &lt;code&gt;name==version&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cowsay==6.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip freeze &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Saved like this, the output becomes &lt;code&gt;requirements.txt&lt;/code&gt;, a recipe for your environment. Commit it, and anyone can rebuild the same setup with &lt;code&gt;python -m pip install -r requirements.txt&lt;/code&gt;. Note that pip itself does not appear in freeze output, because freeze lists project packages, not the installer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Upgrade and Uninstall Packages
&lt;/h2&gt;

&lt;p&gt;Upgrading is routine. Add &lt;code&gt;--upgrade&lt;/code&gt; (short form &lt;code&gt;-U&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip install --upgrade cowsay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our test cowsay was already current, so pip replied "Requirement already satisfied: cowsay in ./.venv/lib/python3.12/site-packages (6.1)". When a newer version exists, pip installs it instead. The same pattern upgrades pip itself: &lt;code&gt;python -m pip install --upgrade pip&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Removing a package is just as clean:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip uninstall cowsay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pip asks for confirmation, then reports "Successfully uninstalled cowsay-6.1". In scripts, add &lt;code&gt;-y&lt;/code&gt; to skip the question. Afterwards, &lt;code&gt;pip list&lt;/code&gt; confirmed only pip 24.0 remained.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Always Use pip Inside a Virtual Environment
&lt;/h2&gt;

&lt;p&gt;A virtual environment is a private folder holding its own Python and packages for one project. When it is active, &lt;code&gt;python -m pip install&lt;/code&gt; puts packages into that folder only. Your system Python stays clean, Project A can keep an older library, and Project B can use the newest one, with no fights.&lt;/p&gt;

&lt;p&gt;Create the environment once with &lt;code&gt;python -m venv .venv&lt;/code&gt;, activate it in each new terminal, then use pip as normal. The Python Packaging Authority's &lt;a href="https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/" rel="noopener noreferrer"&gt;guide to installing packages with pip and virtual environments&lt;/a&gt; walks through the same flow. For the full walkthrough, read our guide to &lt;a href="https://codingcush.com/python-virtual-environments-venv-explained" rel="noopener noreferrer"&gt;Python virtual environments explained with venv&lt;/a&gt;. Think of it this way: pip is the delivery service, and the virtual environment is the address.&lt;/p&gt;

&lt;p&gt;A natural next step is learning how your own functions accept input, in our guide to &lt;a href="https://codingcush.com/python-function-arguments-explained" rel="noopener noreferrer"&gt;Python function arguments: positional, keyword, default, args and kwargs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core pip Commands at a Glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Check pip&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip --version&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows pip version and its Python&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip install cowsay&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Downloads and installs a package from PyPI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exact version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip install "cowsay==6.1"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Installs one specific version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows installed packages and versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show details&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip show cowsay&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows version and install location&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Freeze&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip freeze &amp;gt; requirements.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Saves exact versions to a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install from file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip install -r requirements.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Installs everything in the file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upgrade&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip install --upgrade cowsay&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Moves a package to its newest version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Uninstall&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip uninstall cowsay&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes a package from this environment&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep this table nearby for daily pip work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;"pip is not recognised" or "command not found".&lt;/strong&gt; Usually Python is not on your PATH, or bare &lt;code&gt;pip&lt;/code&gt; fails where &lt;code&gt;python -m pip&lt;/code&gt; works. Try &lt;code&gt;python -m pip --version&lt;/code&gt; first. On Windows, reinstalling Python and ticking "Add Python to PATH" fixes most cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The externally-managed-environment error.&lt;/strong&gt; On many newer Linux systems, installing into the system Python is blocked on purpose. Do not fight it with administrator tricks. The intended fix is Step 5: create a virtual environment and install inside it. The block protects system tools that rely on Python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installed, but the import fails.&lt;/strong&gt; This is the wrong Python problem: you installed with one Python and ran code with another. Compare the Location line from &lt;code&gt;pip show&lt;/code&gt; with your editor's Python, and reinstall with &lt;code&gt;python -m pip&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permission errors.&lt;/strong&gt; If pip cannot write to a folder, resist rerunning as administrator or with &lt;code&gt;sudo&lt;/code&gt;, which can damage a system Python. A virtual environment you own never needs elevated rights, so treat this as a sign you are installing in the wrong place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forgetting to activate.&lt;/strong&gt; The quiet classic: the install succeeds into the global Python and your project still cannot find the package. Check for the environment name in your terminal prompt before every install.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is pip already installed with Python?
&lt;/h3&gt;

&lt;p&gt;Usually, yes. pip has shipped with the standard installers since Python 3.4 via ensurepip. Check with &lt;code&gt;python -m pip --version&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between pip and PyPI?
&lt;/h3&gt;

&lt;p&gt;PyPI is the online library. pip is the tool that downloads packages from PyPI and installs them. One is the shop, the other is the assistant.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I type pip or python -m pip?
&lt;/h3&gt;

&lt;p&gt;Prefer &lt;code&gt;python -m pip&lt;/code&gt;. It installs packages for the exact Python you named, preventing the most common confusion on multi Python machines.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where do pip packages get installed?
&lt;/h3&gt;

&lt;p&gt;Into the site-packages folder of the active environment. Run &lt;code&gt;python -m pip show&lt;/code&gt; with a package name to see its Location.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is requirements.txt for?
&lt;/h3&gt;

&lt;p&gt;It lists your project's packages with exact versions, created by &lt;code&gt;pip freeze&lt;/code&gt;. Anyone can rebuild the same environment with &lt;code&gt;pip install -r requirements.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;pip is not a mysterious extra tool. It is the standard installer that already travels with Python, fetching packages from PyPI so you can stand on the work of other developers. Check it with &lt;code&gt;python -m pip --version&lt;/code&gt;, keep each project inside its own virtual environment, and save your &lt;code&gt;requirements.txt&lt;/code&gt;. Then "just pip install it" becomes an instruction you enjoy.&lt;/p&gt;

</description>
      <category>pip</category>
      <category>pythonpackages</category>
      <category>pypi</category>
      <category>python</category>
    </item>
    <item>
      <title>How to Fix a Git Merge Conflict Step by Step</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:50:07 +0000</pubDate>
      <link>https://dev.to/kushkrg/how-to-fix-a-git-merge-conflict-step-by-step-3kc1</link>
      <guid>https://dev.to/kushkrg/how-to-fix-a-git-merge-conflict-step-by-step-3kc1</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/how-to-fix-git-merge-conflict" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You fix a Git merge conflict by opening the conflicted file, reading the markers Git left inside it, editing the file so only the correct final text remains with no markers left, then running &lt;code&gt;git add&lt;/code&gt; and &lt;code&gt;git commit&lt;/code&gt; to finish the merge. You have not broken anything. A conflict means Git found two different changes to the same lines and refuses to guess which one you want. This guide creates a tiny real conflict on purpose, then fixes it by hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Merge Conflict Actually Is
&lt;/h2&gt;

&lt;p&gt;Git merges branches by comparing changes. If one branch edits the top of a file and the other edits the bottom, Git can combine them on its own. A conflict appears when both branches change the same line, or nearby lines, in different ways. Git has two good answers and no safe way to pick between them, so it stops the merge halfway, marks the file, and asks you to decide.&lt;/p&gt;

&lt;p&gt;Think of two friends editing the same sentence at once. A computer should not silently throw either version away. That pause is a feature, not a failure, even if the warning makes your stomach drop the first time.&lt;/p&gt;

&lt;p&gt;If branch work is still new, our guide to &lt;a href="https://codingcush.com/git-branches-explained" rel="noopener noreferrer"&gt;Git branches explained, including how to create, switch, merge and delete branches&lt;/a&gt;, fills in the background. The &lt;a href="https://git-scm.com/docs/git-merge" rel="noopener noreferrer"&gt;official git merge documentation&lt;/a&gt; states the same rule: resolve a conflict and commit, or abort the merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create a Tiny Conflict on Purpose
&lt;/h2&gt;

&lt;p&gt;Practice in a throwaway folder first. Run these commands, tested for this article with Git 2.43:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init -b main
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'Hello, friend!\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; greeting.txt
git add greeting.txt
git commit -m &lt;span class="s2"&gt;"Add greeting file"&lt;/span&gt;
git checkout -b feature-greeting
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'Hello from the feature branch!\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; greeting.txt
git commit -am &lt;span class="s2"&gt;"Change greeting on feature branch"&lt;/span&gt;
git checkout main
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'Hello from the main branch!\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; greeting.txt
git commit -am &lt;span class="s2"&gt;"Change greeting on main"&lt;/span&gt;
git merge feature-greeting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both branches started from &lt;code&gt;Hello, friend!&lt;/code&gt; and each rewrote that one line differently. That is the exact recipe for a conflict. The merge prints this real output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Auto-merging greeting.txt
CONFLICT (content): Merge conflict in greeting.txt
Automatic merge failed; fix conflicts and then commit the result.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read the last line slowly. Git is giving you the plan: fix the conflicts, then commit. Nothing is lost and neither branch is damaged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Read the Conflict Markers
&lt;/h2&gt;

&lt;p&gt;Open &lt;code&gt;greeting.txt&lt;/code&gt; in any editor. During the conflict it contains exactly this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/span&gt;
Hello from the main branch!
&lt;span class="gu"&gt;=======&lt;/span&gt;
Hello from the feature branch!
&lt;span class="gi"&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature-greeting&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The markers are signposts, not code, and they must never survive into your final file. &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt; starts your current branch version, so the text below it is what your current branch has. The line &lt;code&gt;=======&lt;/code&gt; separates the two versions. Below it sits the incoming version. &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature-greeting&lt;/code&gt; ends the conflict and names the branch you are merging in.&lt;/p&gt;

&lt;p&gt;A bigger file can hold several such blocks. Fix them one at a time, and search for &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; afterwards to be sure none remain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjh45dn4g8wi5a5sucgkm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjh45dn4g8wi5a5sucgkm.png" alt="Terminal window showing the real Git merge conflict session from this article, with the CONFLICT message, the conflict markers, and the successful merge commit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Terminal window showing the real conflict session for this article: the CONFLICT message, the markers in greeting.txt, and the successful merge commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Fix the File by Hand, Step by Step
&lt;/h2&gt;

&lt;p&gt;Decide what the final line should say. You can keep the current version only, keep the incoming version only, or combine them into something new. Combining is best for learning, because it proves the choice is yours. Follow these steps:&lt;/p&gt;

&lt;p&gt;First, delete the marker line &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt;. Second, delete the separator &lt;code&gt;=======&lt;/code&gt;. Third, delete the closing marker &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature-greeting&lt;/code&gt;. Fourth, edit what remains into one clean final line. In our tested session we replaced the whole file with a combined greeting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'Hello, friend, from both of us!\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; greeting.txt
cat greeting.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, friend, from both of us!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In an editor you would type that same line and save. Open the file once more before moving on. It should read like a normal file, with no markers and no leftover duplicate. Yes, Git makes everyone read their own greeting file three times. That is the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Finish with git add and git commit
&lt;/h2&gt;

&lt;p&gt;Editing alone is not enough, because Git does not yet know you are done. Tell it in two steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add greeting.txt
git status
git commit -m &lt;span class="s2"&gt;"Merge feature branch and fix greeting conflict"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After &lt;code&gt;git add&lt;/code&gt;, our real &lt;code&gt;git status&lt;/code&gt; said &lt;code&gt;All conflicts fixed but you are still merging&lt;/code&gt;. That message is your green light. The commit then printed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[main f2f247e] Merge feature branch and fix greeting conflict
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A final &lt;code&gt;git status&lt;/code&gt; reported a clean working tree, so the merge is fully finished. The chapter on &lt;a href="https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging" rel="noopener noreferrer"&gt;basic branching and merging in the Pro Git book&lt;/a&gt; shows the same flow on a larger example. Once your project is merged and clean, you can push it using our guide to &lt;a href="https://codingcush.com/how-to-create-github-repository-and-push-project" rel="noopener noreferrer"&gt;how to create a GitHub repository and push your project&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Abort Safely with git merge --abort
&lt;/h2&gt;

&lt;p&gt;Sometimes the right move is to stop and ask a teammate what their change meant. If a merge is still in progress and not yet committed, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git merge --abort
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns your files to the state just before you ran &lt;code&gt;git merge&lt;/code&gt;. We tested it too: after a second conflict, &lt;code&gt;git status --short&lt;/code&gt; showed &lt;code&gt;UU greeting.txt&lt;/code&gt;, we ran the abort command, and &lt;code&gt;git status&lt;/code&gt; immediately reported a clean tree with the pre merge content back. Aborting is not failure. It is a safe undo for one merge attempt, and you can retry whenever you are ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Helpers: git status and git log --merge
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;git status&lt;/code&gt; at every stage. During a conflict it lists files under &lt;code&gt;Unmerged paths&lt;/code&gt; and reminds you of both exits: commit when fixed, or abort. After &lt;code&gt;git add&lt;/code&gt; it confirms that all conflicts are fixed. When in doubt, ask status first instead of guessing.&lt;/p&gt;

&lt;p&gt;During an open conflict, &lt;code&gt;git log --merge --oneline&lt;/code&gt; lists the commits on both sides that touched the conflicted files, helping you see why each side changed the line. It only works while a merge is in progress. For daily reference, keep our &lt;a href="https://codingcush.com/git-commands-cheat-sheet-for-beginners" rel="noopener noreferrer"&gt;Git commands cheat sheet for beginners with 20 everyday commands&lt;/a&gt; nearby.&lt;/p&gt;

&lt;h2&gt;
  
  
  Edit by Hand, Merge Tool, or Abort: Which Should You Choose?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Watch out for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Edit by hand&lt;/td&gt;
&lt;td&gt;Small conflicts, learning, full control&lt;/td&gt;
&lt;td&gt;You must remove every marker yourself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Merge tool such as &lt;code&gt;git mergetool&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Large files, many conflict blocks&lt;/td&gt;
&lt;td&gt;Still review the final file before committing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abort and retry&lt;/td&gt;
&lt;td&gt;Wrong branch, missing context, need advice&lt;/td&gt;
&lt;td&gt;Only works before you commit the merge&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For beginners, editing by hand wins most of the time, because the markers teach you exactly what Git is asking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Committing the markers.&lt;/strong&gt; If &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; or &lt;code&gt;=======&lt;/code&gt; lines reach a commit, the file is broken. Search every fixed file for &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; before you add it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forgetting git add.&lt;/strong&gt; Editing alone does not mark a conflict as resolved. Until you add the file, &lt;code&gt;git status&lt;/code&gt; keeps listing it as unmerged and the merge will not conclude.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choosing a side without reading it.&lt;/strong&gt; Picking your version just because it is yours can silently delete a teammate's fix. Read both versions first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting the folder in panic.&lt;/strong&gt; Never delete the project or its &lt;code&gt;.git&lt;/code&gt; folder to escape a conflict. Use &lt;code&gt;git merge --abort&lt;/code&gt; instead. It is safe and keeps all history intact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The merge will not abort.&lt;/strong&gt; Abort expects an unfinished merge. If you already committed it, abort no longer applies; get help with undoing a commit instead of trying random reset commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does a merge conflict mean I broke the project?
&lt;/h3&gt;

&lt;p&gt;No. It means two branches changed the same lines differently and Git needs your decision. Your commits and both branches are still safe.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I keep both versions of the line?
&lt;/h3&gt;

&lt;p&gt;Yes. Delete the markers and keep both lines in a sensible order, or combine them into one new line, as this guide did.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if there are conflicts in many files?
&lt;/h3&gt;

&lt;p&gt;Fix one file at a time. Use &lt;code&gt;git status&lt;/code&gt; to see what remains, resolve and add each file, and commit only when all conflicts are fixed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is git merge --abort always safe?
&lt;/h3&gt;

&lt;p&gt;It safely cancels an unfinished merge and restores the pre merge state. It cannot be used after the merge has been committed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A merge conflict is Git asking a question it cannot answer alone. Find the markers, choose or combine the lines, remove every marker, then add and commit. When you need time to think, abort and retry later. Practise once on a tiny greeting file, as we did here, and the next real conflict will feel like a small task instead of a disaster.&lt;/p&gt;

</description>
      <category>gitmergeconflict</category>
      <category>git</category>
      <category>mergeconflict</category>
      <category>devops</category>
    </item>
    <item>
      <title>Recursion Explained with Simple Python Examples</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:49:16 +0000</pubDate>
      <link>https://dev.to/kushkrg/recursion-explained-with-simple-python-examples-3al3</link>
      <guid>https://dev.to/kushkrg/recursion-explained-with-simple-python-examples-3al3</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/recursion-explained-with-examples" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recursion is when a function calls itself to solve a smaller version of the same problem, again and again, until it reaches a simple case it can answer directly. That simple case is the base case, and it stops the function from calling itself forever. In this article you will run four complete Python examples: a countdown, a factorial, the Fibonacci sequence, and the sum of a list. You will also learn how the call stack works, what the Python recursion limit is, and which beginner mistakes to avoid.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Recursion, in Plain Words?
&lt;/h2&gt;

&lt;p&gt;Imagine you are in a long queue and want to know your position. You ask the person in front, who asks the person in front of them, until the question reaches the first person, who can answer at once: "I am number one." The answer then travels back, each person adding one, until you know your position.&lt;/p&gt;

&lt;p&gt;That is recursion. A big problem is passed on as a smaller problem until the answer is obvious, and the small answers are combined on the way back. To revise functions first, see the official tutorial section on &lt;a href="https://docs.python.org/3/tutorial/controlflow.html" rel="noopener noreferrer"&gt;defining functions and control flow in Python&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Two Parts Every Recursive Function Needs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The base case&lt;/strong&gt; is the smallest version of the problem, the one the function can answer directly without calling itself. In the queue story, it is the first person.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The recursive case&lt;/strong&gt; is everything else. The function does a small piece of work, then calls itself with an input one step closer to the base case. Every call must move closer, or the function will never stop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1: A Simple Countdown
&lt;/h2&gt;

&lt;p&gt;The countdown is the friendliest first example, because you can watch the calls in the output. The function prints a number, then calls itself with a number one smaller.&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;def&lt;/span&gt; &lt;span class="nf"&gt;countdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Blast off!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;countdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;countdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The line &lt;code&gt;if n &amp;lt;= 0&lt;/code&gt; is the base case. The &lt;code&gt;else&lt;/code&gt; block is the recursive case: it prints the number and calls &lt;code&gt;countdown(n - 1)&lt;/code&gt;, one step closer to zero. The output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5
4
3
2
1
Blast off!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example 2: Factorial of a Number
&lt;/h2&gt;

&lt;p&gt;The factorial of a number is that number multiplied by every whole number below it down to one, so 5! is 5 x 4 x 3 x 2 x 1, which equals 120. It also has a neat recursive definition: n! equals n multiplied by (n - 1)!.&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;def&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The base case says the factorial of 0 and of 1 are both 1. The recursive case returns &lt;code&gt;n * factorial(n - 1)&lt;/code&gt;, so factorial(5) becomes 5 x factorial(4), then 4 x factorial(3), until factorial(1) returns 1 and the multiplications happen on the way back. The output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;120
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example 3: Fibonacci Numbers
&lt;/h2&gt;

&lt;p&gt;In the Fibonacci sequence, each number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, and so on. This one needs two base cases.&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;def&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The recursive case adds two smaller calls. The output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;8
[0, 1, 1, 2, 3, 5, 8, 13]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5loymg7in158334nw8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5loymg7in158334nw8t.png" alt="Terminal window showing the real Python output of the recursion examples in this article, including the countdown, factorial and Fibonacci results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A terminal window showing the real output of this article's Python recursion examples, including the countdown, the factorial results and the Fibonacci sequence.&lt;/p&gt;

&lt;p&gt;A friendly warning: this neat version is slow for larger numbers, because it repeats work. Finding fibonacci(6) calls fibonacci(5) and fibonacci(4), and fibonacci(5) calls fibonacci(4) again, so the same problems get solved many times and the calls grow very fast. Storing results in a dictionary, called memoisation, can fix this. Growth like this is easier to judge with our guide to &lt;a href="https://codingcush.com/what-is-big-o-notation" rel="noopener noreferrer"&gt;Big O notation and how algorithm growth is measured&lt;/a&gt; and our walkthrough of &lt;a href="https://codingcush.com/time-complexity-in-python-explained" rel="noopener noreferrer"&gt;time complexity in Python with everyday examples&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 4: Sum of a List
&lt;/h2&gt;

&lt;p&gt;The sum of a list is the first item plus the sum of the rest, and the sum of an empty list is zero, which is the base case.&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;def&lt;/span&gt; &lt;span class="nf"&gt;sum_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;sum_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sum_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each call takes the first number out and asks a smaller call to handle the rest. The output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In real projects you would use the built in &lt;code&gt;sum()&lt;/code&gt; function, which is shorter and faster. The recursive version is still worth learning, because the same pattern appears in trees, nested folders, and interview questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is the Call Stack?
&lt;/h2&gt;

&lt;p&gt;When a function calls itself, Python must remember where each unfinished call stopped and where to return its result. It stores this on the call stack, which you can picture as a pile of plates: each new call adds a plate, and a call can only finish when the calls above it have finished.&lt;/p&gt;

&lt;p&gt;Take factorial(3). It waits for factorial(2), which waits for factorial(1), the base case, which returns 1. Then the stack unwinds: factorial(2) returns 2, and factorial(3) returns 6. This last in, first out behaviour is why the stack matters, and our comparison of &lt;a href="https://codingcush.com/stack-vs-queue-difference" rel="noopener noreferrer"&gt;the stack and queue data structures and their key differences&lt;/a&gt; explains it with more examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Python Recursion Limit and RecursionError
&lt;/h2&gt;

&lt;p&gt;Every unfinished call uses memory, so Python protects your program with a recursion limit. Call too deeply and Python raises a &lt;code&gt;RecursionError&lt;/code&gt; instead of crashing. Check your limit like this:&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;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getrecursionlimit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the machine used to test this article, the output was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your number will most likely also be 1000, the usual default. The &lt;a href="https://docs.python.org/3/library/sys.html" rel="noopener noreferrer"&gt;official documentation for the sys module in Python&lt;/a&gt; describes this limit in detail. You can raise it with &lt;code&gt;sys.setrecursionlimit()&lt;/code&gt;, but treat that as an expert tool, not a fix: hitting the limit usually means a missing base case, so fix the logic first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recursion or a Loop: Which Should You Use?
&lt;/h2&gt;

&lt;p&gt;Anything written with recursion can also be written with a loop. Use the version that is clearer and safer for your data size.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Point to compare&lt;/th&gt;
&lt;th&gt;Recursion&lt;/th&gt;
&lt;th&gt;Loop&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;How it repeats&lt;/td&gt;
&lt;td&gt;A function calls itself with a smaller input&lt;/td&gt;
&lt;td&gt;A for or while block repeats steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How it stops&lt;/td&gt;
&lt;td&gt;When the base case is reached&lt;/td&gt;
&lt;td&gt;When the loop condition becomes false&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory use&lt;/td&gt;
&lt;td&gt;Uses the call stack, so deep calls cost memory&lt;/td&gt;
&lt;td&gt;Usually uses very little extra memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Trees, nested data, divide and conquer problems&lt;/td&gt;
&lt;td&gt;Simple counting, lists, long repetition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Main risk&lt;/td&gt;
&lt;td&gt;RecursionError if the calls go too deep&lt;/td&gt;
&lt;td&gt;An infinite loop if the condition never changes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A simple rule: if the problem is nested or branching, try recursion. If it is a long, straight line of steps, use a loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Forgetting the base case.&lt;/strong&gt; The function calls itself until Python raises a RecursionError. Fix: write the base case first, every time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The input never gets smaller.&lt;/strong&gt; Calling &lt;code&gt;countdown(n)&lt;/code&gt; instead of &lt;code&gt;countdown(n - 1)&lt;/code&gt; means the base case is never reached. Fix: check every call moves closer to it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forgetting to return the recursive call.&lt;/strong&gt; Writing &lt;code&gt;factorial(n - 1)&lt;/code&gt; on its own throws the answer away, and the function returns None. Fix: the recursive call is usually part of a return statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expecting the naive Fibonacci code to be fast.&lt;/strong&gt; It repeats work, so large inputs crawl. Fix: use a loop, or store results already worked out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Raising the limit to hide a bug.&lt;/strong&gt; A higher limit only delays the crash. Fix: print the argument for a small input and check the values move towards the base case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is recursion hard to learn?
&lt;/h3&gt;

&lt;p&gt;No, it only feels strange at first. Trace one small example on paper and the idea usually clicks within an hour.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens if a recursive function has no base case?
&lt;/h3&gt;

&lt;p&gt;It keeps calling itself until Python raises a RecursionError, so always write the base case first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is recursion faster than a loop in Python?
&lt;/h3&gt;

&lt;p&gt;Usually no. Loops are normally faster and use less memory. Recursion wins on clarity for nested problems, not speed.&lt;/p&gt;

&lt;h3&gt;
  
  
  When should I use recursion in real projects?
&lt;/h3&gt;

&lt;p&gt;Use it when the data is nested, such as folders inside folders, comments with replies, or splitting a problem into halves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Recursion is simply a function that calls itself on a smaller problem until it reaches a base case it can answer directly. You have seen it count down, build a factorial, grow the Fibonacci sequence, and add up a list. Pick one example, type it yourself, break it by removing the base case, then fix it. That small experiment teaches more than ten definitions. Happy coding, and yes, this conclusion was written by a human, not by a function calling itself.&lt;/p&gt;

</description>
      <category>recursion</category>
      <category>pythonrecursion</category>
      <category>datastructures</category>
      <category>python</category>
    </item>
    <item>
      <title>What Is CORS? Why Your API Request Is Blocked and How to Fix It</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Fri, 13 Nov 2026 05:49:11 +0000</pubDate>
      <link>https://dev.to/kushkrg/what-is-cors-why-your-api-request-is-blocked-and-how-to-fix-it-25bd</link>
      <guid>https://dev.to/kushkrg/what-is-cors-why-your-api-request-is-blocked-and-how-to-fix-it-25bd</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/what-is-cors-explained-fix" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;CORS, short for Cross-Origin Resource Sharing, is the browser rule that decides whether JavaScript on one website may read data from another site's server. When you see the console error "blocked by CORS policy", it means your page asked an API for data, the API answered, and the browser refused to hand the answer to your code because the server did not give permission. In this guide you will learn what an origin is, why the browser blocks first and asks questions later, what a preflight request is, and how to fix CORS properly on the server, with a small Node.js example we tested live with curl.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, What Is an Origin?
&lt;/h2&gt;

&lt;p&gt;An origin is the combination of three things: the scheme, the host and the port. &lt;code&gt;https://codingcush.com&lt;/code&gt; and &lt;code&gt;http://codingcush.com&lt;/code&gt; are different origins because the scheme differs. &lt;code&gt;https://codingcush.com&lt;/code&gt; and &lt;code&gt;https://api.codingcush.com&lt;/code&gt; are different origins because the host differs. Even &lt;code&gt;http://localhost:3000&lt;/code&gt; and &lt;code&gt;http://localhost:5000&lt;/code&gt;, your own laptop twice, are different origins because the port differs. Two pages with the same origin may freely read each other's responses. Cross that line, and CORS becomes the gatekeeper.&lt;/p&gt;

&lt;p&gt;Here is the part that surprises everyone: the request usually still reaches the server, and the server often answers correctly. You can prove it in the Network tab, and it is why the same URL works in curl or Postman. CORS is a browser protection, not a server firewall. It exists so that a random website you visit cannot use your browser, and your logged-in sessions, to quietly read data from other sites. The server must opt in, out loud, in its response headers, before the browser will share the response with the page's JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  The One Header That Fixes Most Cases
&lt;/h2&gt;

&lt;p&gt;Permission is given with a response header called &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;. When your browser sends a request, it adds an &lt;code&gt;Origin&lt;/code&gt; header saying where the page came from. The server replies, and if the response contains &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; naming your origin (or the wildcard &lt;code&gt;*&lt;/code&gt; for public data), the browser releases the response to your code. No matching header, no data. The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS" rel="noopener noreferrer"&gt;MDN guide to Cross-Origin Resource Sharing&lt;/a&gt; describes this handshake in full, and it is worth a careful read once the basics below feel familiar.&lt;/p&gt;

&lt;p&gt;These headers belong to the same family as the request and response headers you meet every day, so if names like &lt;code&gt;Host&lt;/code&gt; and &lt;code&gt;Content-Type&lt;/code&gt; are new, our guide to &lt;a href="https://codingcush.com/http-headers-explained" rel="noopener noreferrer"&gt;HTTP headers explained: what they are and how they work&lt;/a&gt; is the friendly place to start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Requests vs Preflighted Requests
&lt;/h2&gt;

&lt;p&gt;Not every cross-origin request is treated the same way:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Simple request&lt;/th&gt;
&lt;th&gt;Preflighted request&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Methods&lt;/td&gt;
&lt;td&gt;GET, HEAD, or POST&lt;/td&gt;
&lt;td&gt;Any, including PUT, PATCH, DELETE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Headers&lt;/td&gt;
&lt;td&gt;Only simple ones, such as a plain form-style Content-Type&lt;/td&gt;
&lt;td&gt;Custom headers, or Content-Type: application/json&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extra step&lt;/td&gt;
&lt;td&gt;None: the request is sent at once&lt;/td&gt;
&lt;td&gt;The browser first sends an OPTIONS preflight to ask permission&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical case&lt;/td&gt;
&lt;td&gt;Fetching public JSON with a plain GET&lt;/td&gt;
&lt;td&gt;Sending JSON or an Authorization header to an API&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The preflight is the browser asking, before the real request: "A page from this origin wants to send a POST with a JSON body and these headers. Is that acceptable?" The server answers the OPTIONS request with &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;, &lt;code&gt;Access-Control-Allow-Methods&lt;/code&gt; and &lt;code&gt;Access-Control-Allow-Headers&lt;/code&gt;. Only a yes lets the real request follow. This is why your server logs sometimes show an OPTIONS hit you never wrote code for. The browser sent it, politely, on your behalf.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Working Fix: A Tiny Node.js API with CORS Headers
&lt;/h2&gt;

&lt;p&gt;Here is a complete API with no framework, tested for this article. It sets the three headers on every response and answers preflights with a 204:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const http = require("http");

const server = http.createServer((req, res) =&amp;gt; {
  res.setHeader("Access-Control-Allow-Origin", "https://codingcush.com");
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
  res.setHeader("Access-Control-Allow-Headers", "Content-Type");

  if (req.method === "OPTIONS") {
    res.writeHead(204);
    res.end();
    return;
  }

  res.setHeader("Content-Type", "application/json");
  res.end(JSON.stringify({ message: "Hello from the API" }));
});

server.listen(3456, () =&amp;gt; {
  console.log("API listening on http://127.0.0.1:3456");
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two habits in this code matter in real projects. First, the allowed origin is one named site, not &lt;code&gt;*&lt;/code&gt;. The wildcard is fine for a fully public API, but it cannot be combined with credentials such as cookies, and it invites every website on the internet to read your responses. Second, the headers are set before any branching, so error responses carry them too; a 500 without CORS headers produces the same confusing browser error as a blocked 200.&lt;/p&gt;

&lt;p&gt;We verified the server with curl, sending the same Origin header a browser would send:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -i -H "Origin: https://codingcush.com" http://127.0.0.1:3456/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real output from that test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 OK
Access-Control-Allow-Origin: https://codingcush.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
Content-Type: application/json

{"message":"Hello from the API"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the preflight test, an OPTIONS request, answered &lt;code&gt;HTTP/1.1 204 No Content&lt;/code&gt; with the same three Access-Control headers. If your own API fails this curl test, no browser setting will save you; the fix belongs on the server. The reference page for &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Origin" rel="noopener noreferrer"&gt;the Access-Control-Allow-Origin header on MDN&lt;/a&gt; lists every valid form of the header when you need the exact rules.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdedilupbna939qqtjruf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdedilupbna939qqtjruf.png" alt="Terminal window showing the real curl test of the Node.js CORS server in this article: a 200 response carrying Access-Control-Allow-Origin for codingcush.com, and a 204 preflight answer" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The real curl test of the CORS server in this article: the normal request returns 200 with Access-Control-Allow-Origin naming the allowed site, and the OPTIONS preflight returns 204 with the same permission headers.&lt;/p&gt;

&lt;h2&gt;
  
  
  How This Looks from the Fetch Side
&lt;/h2&gt;

&lt;p&gt;From the page's point of view, nothing about your code changes. A normal call such as the ones in our guide to &lt;a href="https://codingcush.com/javascript-fetch-api-explained" rel="noopener noreferrer"&gt;how to fetch data from an API in JavaScript&lt;/a&gt; works as soon as the server grants permission:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://api.example.com/data")
  .then((response) =&amp;gt; response.json())
  .then((data) =&amp;gt; console.log(data))
  .catch((error) =&amp;gt; console.log("Request failed:", error.message));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that a CORS failure lands in &lt;code&gt;catch&lt;/code&gt; with a plain network-style error. JavaScript is deliberately told almost nothing about why, for security reasons; the real explanation lives only in the browser console. So when fetch fails and the server looks healthy, read the console message carefully: it names the origin, the missing header, or the failed preflight, and that sentence is your actual bug report. If APIs themselves are still new to you, start with our explainer on &lt;a href="https://codingcush.com/what-is-an-api-explained-simply" rel="noopener noreferrer"&gt;what an API is, explained simply&lt;/a&gt;, then come back to the gatekeeper.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Trying to fix CORS from the frontend.&lt;/strong&gt; There is no frontend fix, by design. Adding headers to your fetch request does not grant permission; only the server's response headers do. If the API is not yours, you need the API owner to allow your origin, or a small backend of your own that calls the API server-side, where CORS does not apply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the wildcard with credentials.&lt;/strong&gt; &lt;code&gt;Access-Control-Allow-Origin: *&lt;/code&gt; plus cookies or an Authorization flow will still be blocked. Name the exact origin, and have the server also send &lt;code&gt;Access-Control-Allow-Credentials: true&lt;/code&gt; when cookies must travel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answering the GET but not the OPTIONS.&lt;/strong&gt; If your framework route handles POST but the preflight OPTIONS falls through to a 404, the browser stops before the real request. Test preflights with curl exactly as shown above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blaming CORS for a plain network failure.&lt;/strong&gt; If curl cannot reach the server either, the problem is DNS, a stopped server, or a wrong URL, not CORS. CORS errors only appear when the server answered and the browser withheld the answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing a browser extension to "disable CORS".&lt;/strong&gt; Fine for a five-minute local test, dangerous as a habit, and it fixes nothing for your visitors. Always land the real fix on the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why does the same API work in Postman but not in the browser?
&lt;/h3&gt;

&lt;p&gt;Postman and curl are not browsers, so they do not enforce CORS. They show you the raw response. The browser adds the permission check on top, which is why "it works in Postman" is the classic CORS symptom.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is CORS a security feature of my server?
&lt;/h3&gt;

&lt;p&gt;It protects users and other websites, inside the browser. It does not stop anyone from calling your API with other tools, so never treat CORS as your API's security. Authentication and rate limits are separate jobs.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does "preflight" mean in simple words?
&lt;/h3&gt;

&lt;p&gt;Before sending a non-simple cross-origin request, the browser sends a small OPTIONS request asking the server for permission, listing the method and headers it plans to use. A correct answer lets the real request through.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I allow several origins?
&lt;/h3&gt;

&lt;p&gt;Yes. The header holds one origin per response, so servers usually check the incoming Origin header against an allow-list and echo back whichever one matched. Frameworks and CORS middleware packages automate exactly that check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;CORS is not your API being broken; it is your browser asking for a permission slip the server forgot to sign. Name your origin in &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;, answer preflights with the methods and headers your API accepts, verify both with curl, and the red console error turns back into the quiet, working fetch you expected all along.&lt;/p&gt;

</description>
      <category>cors</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>api</category>
    </item>
    <item>
      <title>Python Virtual Environments Explained: Create and Use venv</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Fri, 13 Nov 2026 05:48:14 +0000</pubDate>
      <link>https://dev.to/kushkrg/python-virtual-environments-explained-create-and-use-venv-g9h</link>
      <guid>https://dev.to/kushkrg/python-virtual-environments-explained-create-and-use-venv-g9h</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/python-virtual-environments-venv-explained" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A Python virtual environment is a private folder that holds its own Python interpreter copy and its own set of installed packages, separate from every other project on your computer. You create one with a single built-in command, &lt;code&gt;python -m venv .venv&lt;/code&gt;, activate it, and from then on &lt;code&gt;pip install&lt;/code&gt; puts packages into that folder only. In this guide you will learn why environments matter, how to create, activate and rebuild one step by step, and how to fix the problems beginners meet most, with every command tested on Python 3.12.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do You Need a Virtual Environment at All?
&lt;/h2&gt;

&lt;p&gt;Picture two projects on one laptop. Project A needs version 1 of a library. Project B needs version 2 of the same library. If both projects share one global Python, installing version 2 for Project B can break Project A, and the error will appear days later, in code you did not touch, which is a special kind of frustrating.&lt;/p&gt;

&lt;p&gt;A virtual environment solves this with simple isolation: one folder per project, one package set per folder. The &lt;a href="https://docs.python.org/3/library/venv.html" rel="noopener noreferrer"&gt;official venv documentation&lt;/a&gt; describes an environment as a directory with its own independent set of packages, created on top of your existing Python installation and isolated from it by default. The tool is called &lt;code&gt;venv&lt;/code&gt;, it ships with Python 3.3 and later, and it costs nothing. There is no good reason to skip it, even for small scripts you plan to share.&lt;/p&gt;

&lt;h2&gt;
  
  
  What You Need Before You Start
&lt;/h2&gt;

&lt;p&gt;You need Python 3 installed and reachable from your terminal. Check with &lt;code&gt;python --version&lt;/code&gt; on Windows or &lt;code&gt;python3 --version&lt;/code&gt; on Mac and Linux. If Python is missing, our step-by-step guide to &lt;a href="https://codingcush.com/how-to-install-python-on-windows-vs-code" rel="noopener noreferrer"&gt;how to install Python on Windows and set up VS Code&lt;/a&gt; gets you to a working setup first, including the famous PATH checkbox that everyone forgets once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create the Environment
&lt;/h2&gt;

&lt;p&gt;Open a terminal inside your project folder and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv .venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Mac and Linux, use &lt;code&gt;python3 -m venv .venv&lt;/code&gt; if &lt;code&gt;python&lt;/code&gt; is not available. Let us unpack the command, because every part earns its place. &lt;code&gt;-m&lt;/code&gt; tells Python to run a module as a program. &lt;code&gt;venv&lt;/code&gt; is the module. &lt;code&gt;.venv&lt;/code&gt; is the folder to create; the name is a convention, and the leading dot keeps it quietly out of the way. Python builds the folder with a copy or link of the interpreter, a &lt;code&gt;pip&lt;/code&gt; of its own, and a small &lt;code&gt;pyvenv.cfg&lt;/code&gt; file that records where the base Python lives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Activate It
&lt;/h2&gt;

&lt;p&gt;Creating the folder is not enough. You must activate the environment in each new terminal window, so that &lt;code&gt;python&lt;/code&gt; and &lt;code&gt;pip&lt;/code&gt; point inside the folder:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;System and shell&lt;/th&gt;
&lt;th&gt;Activate command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows, Command Prompt&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.venv\Scripts\activate.bat&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows, PowerShell&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.venv\Scripts\Activate.ps1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mac and Linux, bash or zsh&lt;/td&gt;
&lt;td&gt;&lt;code&gt;source .venv/bin/activate&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On Windows PowerShell, if activation is blocked by the execution policy, the official docs suggest allowing local scripts for your user once with &lt;code&gt;Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser&lt;/code&gt;. When activation works, your prompt gains a &lt;code&gt;(.venv)&lt;/code&gt; prefix, like a name badge that says this terminal now works for this project only.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Prove It Works, Then Install Something
&lt;/h2&gt;

&lt;p&gt;Do not trust the name badge alone. Run these two checks (tested on Python 3.12.3):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip --version
python -c "import sys; print(sys.prefix != sys.base_prefix)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command should report a pip path inside your project's &lt;code&gt;.venv&lt;/code&gt; folder, not a system path. The second prints &lt;code&gt;True&lt;/code&gt; when Python is genuinely running from a virtual environment, because inside one, &lt;code&gt;sys.prefix&lt;/code&gt; points at the environment while &lt;code&gt;sys.base_prefix&lt;/code&gt; still points at the base install. Now install packages as usual, for example &lt;code&gt;pip install requests&lt;/code&gt;. They land in &lt;code&gt;.venv&lt;/code&gt; only. Your other projects will never know.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4j79z4s9glabxwytjlbz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4j79z4s9glabxwytjlbz.png" alt="Terminal window showing a real venv session run on Python 3.12: creating .venv, activating it, pip reporting its path inside .venv, and the sys.prefix check printing True" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A real venv session run for this article on Python 3.12: after activation, pip reports its path inside the project's .venv folder, and the sys.prefix check prints True, proving the environment is active.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Save and Rebuild with requirements.txt
&lt;/h2&gt;

&lt;p&gt;An environment is disposable by design; the recipe to rebuild it is what you keep. Save the recipe with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip freeze &amp;gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That file lists every installed package with its exact version. Commit &lt;code&gt;requirements.txt&lt;/code&gt; to Git, and never commit the &lt;code&gt;.venv&lt;/code&gt; folder itself; since Python 3.13, venv even writes a starter &lt;code&gt;.gitignore&lt;/code&gt; inside the folder to help with exactly that. On a new machine, anyone can rebuild your setup in two lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv .venv
pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember the second line runs after activation. The Python Packaging Authority's &lt;a href="https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/" rel="noopener noreferrer"&gt;guide to pip and virtual environments&lt;/a&gt; walks through the same create, activate, install flow if you want a second explanation. And when you finish working, &lt;code&gt;deactivate&lt;/code&gt; returns the terminal to the global Python; the folder stays on disk, ready for tomorrow.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Complete Tiny Workflow, Start to Finish
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir myproject
cd myproject
python -m venv .venv
source .venv/bin/activate
pip install requests
pip freeze &amp;gt; requirements.txt
deactivate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the whole habit. It takes under a minute once your fingers learn it, and it quietly prevents the most confusing category of beginner Python bugs: the ones caused by the wrong package version being installed in the wrong place. It also makes helping you much easier: when someone asks what your project needs, you send one small text file instead of a paragraph of guesses, and they can rebuild your exact setup on their own machine and see the same behaviour you see. The habit also pairs well with structuring your code properly; our guide to &lt;a href="https://codingcush.com/python-function-arguments-explained" rel="noopener noreferrer"&gt;Python function arguments: positional, keyword, default, args and kwargs&lt;/a&gt; is a good next step once your project runs in its own clean environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Forgetting to activate.&lt;/strong&gt; The number one issue. You install a package, Python says the module is missing, and the package is sitting happily in the global Python instead. Check for the &lt;code&gt;(.venv)&lt;/code&gt; prompt prefix before every &lt;code&gt;pip install&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Committing .venv to Git.&lt;/strong&gt; The folder is large, machine-specific and rebuildable. Commit &lt;code&gt;requirements.txt&lt;/code&gt; instead, and add &lt;code&gt;.venv/&lt;/code&gt; to your &lt;code&gt;.gitignore&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Moving or renaming the project folder.&lt;/strong&gt; Environments remember absolute paths, so a moved &lt;code&gt;.venv&lt;/code&gt; often breaks. The official advice is simple: delete it and recreate it from &lt;code&gt;requirements.txt&lt;/code&gt;. It takes a minute and always works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two Pythons, one confused terminal.&lt;/strong&gt; If &lt;code&gt;pip --version&lt;/code&gt; shows a path outside &lt;code&gt;.venv&lt;/code&gt; after activation, close the terminal, open a fresh one in the project folder and activate again. Stale shells cause most of these mysteries. If errors still mention modules you did install, our guide to &lt;a href="https://codingcush.com/python-error-handling-try-except-finally" rel="noopener noreferrer"&gt;Python error handling with try, except and finally&lt;/a&gt; helps you read the traceback calmly instead of guessing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using one environment for everything.&lt;/strong&gt; That recreates the original problem with extra steps. One project, one environment. Always.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is venv built into Python, or do I install it?
&lt;/h3&gt;

&lt;p&gt;It is built in. The venv module has been part of the standard library since Python 3.3, so &lt;code&gt;python -m venv .venv&lt;/code&gt; works on a plain install with nothing extra to download.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should I name my environment?
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;.venv&lt;/code&gt;. It is the most common convention, editors such as VS Code detect it automatically, and future you will always know what the folder is.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does a virtual environment contain my project code?
&lt;/h3&gt;

&lt;p&gt;No. Your code lives in the project folder as usual. The environment folder holds only the interpreter links and installed packages, and you should never place your own files inside it.&lt;/p&gt;

&lt;h3&gt;
  
  
  venv or virtualenv: which should a beginner use?
&lt;/h3&gt;

&lt;p&gt;Start with venv. It is built in, well documented and enough for nearly every beginner project. The older third-party virtualenv tool adds a few advanced options you can explore later if you ever need them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;One command creates the environment, one command activates it, and one small file, &lt;code&gt;requirements.txt&lt;/code&gt;, makes the whole setup reproducible anywhere. That tiny routine is the difference between "it works on my machine" as a joke and "it works on my machine" as a promise. Make it the first thing you do in every new Python project, starting with your very next one.&lt;/p&gt;

</description>
      <category>python</category>
      <category>venv</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JavaScript Closures Explained with Simple Examples</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Fri, 13 Nov 2026 05:47:12 +0000</pubDate>
      <link>https://dev.to/kushkrg/javascript-closures-explained-with-simple-examples-3hk2</link>
      <guid>https://dev.to/kushkrg/javascript-closures-explained-with-simple-examples-3hk2</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/javascript-closures-explained" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A closure is a function that remembers the variables from the place where it was created, even after that place has finished running. That sentence explains a lot of JavaScript behaviour that feels like magic at first: counters that keep counting, buttons that remember their own value, and helpers that carry private data. In this guide you will learn what a closure really is, how lexical scope makes it work, and how to use closures in real code, with every example tested in Node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Closure, in Plain Words?
&lt;/h2&gt;

&lt;p&gt;Imagine a backpack. When a function is created inside another function, JavaScript quietly packs the variables around it into a backpack and hands that backpack to the inner function. Wherever the inner function goes later, the backpack goes with it. The inner function can open the backpack and use those variables at any time.&lt;/p&gt;

&lt;p&gt;The formal definition is not much scarier. A closure is the combination of a function and the environment in which it was declared. The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures" rel="noopener noreferrer"&gt;MDN guide to closures&lt;/a&gt; puts it this way: a closure gives a function access to its outer scope, and closures are created every time a function is created. You have probably written dozens already without knowing the name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: See the Smallest Possible Closure
&lt;/h2&gt;

&lt;p&gt;Start with an outer function that creates a variable and an inner function that uses it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Asha"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sayHello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hello, "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;sayHello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, Asha
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;sayHello&lt;/code&gt; has no variable called &lt;code&gt;name&lt;/code&gt; of its own. It borrows &lt;code&gt;name&lt;/code&gt; from &lt;code&gt;greet&lt;/code&gt;, the function it was born inside. This works because of &lt;strong&gt;lexical scope&lt;/strong&gt;: JavaScript decides where a variable comes from by looking at where the code is written, not where it is called from. If the variable is not found in the inner function, JavaScript looks one level out, then another, until it reaches the global scope.&lt;/p&gt;

&lt;p&gt;This example is a closure in its simplest clothing, but nothing surprising happens yet, because &lt;code&gt;sayHello&lt;/code&gt; runs while &lt;code&gt;greet&lt;/code&gt; is still alive. The real trick appears when the inner function outlives the outer one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: A Function That Returns a Function
&lt;/h2&gt;

&lt;p&gt;Now return the inner function instead of calling it straight away:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;makeGreeter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Asha"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hello, "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;greetAsha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makeGreeter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;greetAsha&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, Asha
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look closely at the last two lines. &lt;code&gt;makeGreeter()&lt;/code&gt; has finished running. In many languages, its local variable &lt;code&gt;name&lt;/code&gt; would now be gone, like chalk wiped off a board. But &lt;code&gt;greetAsha()&lt;/code&gt; still prints "Asha". The returned function kept its backpack. That memory is the closure.&lt;/p&gt;

&lt;p&gt;Scope behaviour depends on how you declare variables, which is why the difference in our guide to &lt;a href="https://codingcush.com/var-vs-let-vs-const-javascript-difference" rel="noopener noreferrer"&gt;var vs let vs const in JavaScript and what the difference is&lt;/a&gt; matters so much here: closures capture variables declared with any of them, but &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; give each block its own copy, as you will see in the loop example below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Build a Counter (The Classic Interview Example)
&lt;/h2&gt;

&lt;p&gt;Here is the example interviewers love, because it shows closures doing real work: keeping state private.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;makeCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&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="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="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makeCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output (tested with Node.js):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;11
12
13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things are happening. First, &lt;code&gt;count&lt;/code&gt; survives between calls, because the returned function closes over it. Second, nobody outside can touch &lt;code&gt;count&lt;/code&gt; directly; that is free privacy, no classes needed. Third, every call to &lt;code&gt;makeCounter&lt;/code&gt; creates a fresh backpack, so &lt;code&gt;makeCounter(100)&lt;/code&gt; counts from 100 without disturbing the first counter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpjz5tbp6vrdf51t87ncq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpjz5tbp6vrdf51t87ncq.png" alt="Terminal window showing the real output of the closure examples in this article run with Node.js: the counter printing 11, 12, 13, makeAdder printing 7 and 12, and the var and let loop results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The real output of the examples in this article, run with Node.js: the counter prints 11, 12, 13, the adder factory prints 7 and 12, and the loop test shows var printing 3 three times while let prints 0, 1, 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Function Factories with makeAdder
&lt;/h2&gt;

&lt;p&gt;A closure can also remember a setting, which turns a function into a small factory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;makeAdder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;add5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makeAdder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;add10&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makeAdder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output (tested with Node.js):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7
12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;add5&lt;/code&gt; and &lt;code&gt;add10&lt;/code&gt; share the same code but carry different backpacks: one remembers &lt;code&gt;x&lt;/code&gt; as 5, the other as 10. This pattern sits behind a lot of real code: event handlers that remember which item they belong to, middleware that remembers its options, and callbacks in general. That is also why closures pair naturally with asynchronous code, as our guide to &lt;a href="https://codingcush.com/javascript-promises-async-await-explained" rel="noopener noreferrer"&gt;JavaScript promises and async/await explained with simple examples&lt;/a&gt; shows: the function you hand over today brings its variables with it tomorrow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: The Famous Loop Problem (and the let Fix)
&lt;/h2&gt;

&lt;p&gt;This example has embarrassed many of us in interviews, so meet it here first, in friendly conditions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"var"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"let"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output (tested with Node.js):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why does &lt;code&gt;var&lt;/code&gt; print 3 three times? All three callbacks close over the &lt;em&gt;same&lt;/em&gt; variable &lt;code&gt;i&lt;/code&gt;, and by the time the timers fire, the loop has finished and &lt;code&gt;i&lt;/code&gt; is 3. With &lt;code&gt;let&lt;/code&gt;, each round gets its own fresh &lt;code&gt;j&lt;/code&gt;, so each callback remembers a different backpack. Same closures, different scope rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Closures Show Up in Real Projects
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use case&lt;/th&gt;
&lt;th&gt;What the closure remembers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Click handlers&lt;/td&gt;
&lt;td&gt;Which item, tab or button the handler belongs to&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Counters and ID generators&lt;/td&gt;
&lt;td&gt;The last number used, kept private&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Function factories&lt;/td&gt;
&lt;td&gt;A setting such as a tax rate, a prefix or a limit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debounce and throttle helpers&lt;/td&gt;
&lt;td&gt;The timer ID and the last call time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module pattern&lt;/td&gt;
&lt;td&gt;Private data that only the returned methods can reach&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;React hooks such as useState&lt;/td&gt;
&lt;td&gt;The current state value between renders&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Closures also power the handlers you attach when you change a page by hand, as in our guide to &lt;a href="https://codingcush.com/what-is-dom-in-javascript" rel="noopener noreferrer"&gt;what the DOM is in JavaScript, explained simply&lt;/a&gt;: every click callback remembers the elements and values from its birthplace. One honest warning: a closure keeps its variables alive while the function is reachable, so a forgotten listener can hold on to a large object. Long-lived closures deserve housekeeping, like anything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Expecting a fresh copy with var in a loop.&lt;/strong&gt; You saw the output above: three callbacks, one shared variable. Use &lt;code&gt;let&lt;/code&gt; in the loop, or pass the value into an inner function straight away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thinking the closure copies the value.&lt;/strong&gt; A closure captures the variable, not a photograph of it. If the outer code changes the variable later, the inner function sees the new value. This is a feature for counters and a surprise for everyone else, once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating closures in hot loops without noticing.&lt;/strong&gt; Defining a function inside a loop creates a new closure each round. Usually fine, but in tight loops over thousands of items, define the function once outside and pass values in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confusing closures with scope itself.&lt;/strong&gt; Scope is the rule book that decides which variables a piece of code can see. A closure is what you get when a function keeps access to that scope after the outer function returns. The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions" rel="noopener noreferrer"&gt;MDN functions guide&lt;/a&gt; is a good next read if the rule book still feels fuzzy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is every function in JavaScript a closure?
&lt;/h3&gt;

&lt;p&gt;Practically, yes. Every function is created with a link to the scope around it. The word closure is usually used when that link becomes interesting, most often when an inner function is returned or passed as a callback and used after the outer function ends.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a closure and scope?
&lt;/h3&gt;

&lt;p&gt;Scope is the set of variables a piece of code can access, decided by where the code is written. A closure is a function bundled together with the variables from its birthplace scope, so it can keep using them later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do closures waste memory?
&lt;/h3&gt;

&lt;p&gt;They keep the captured variables alive while the function is reachable, which is exactly what counters and handlers need. Problems start only when closures outlive their purpose, for example listeners that are never removed on long-lived pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I practise closures?
&lt;/h3&gt;

&lt;p&gt;Write the counter and the adder factory from this article without looking, predict each output before you run it, then try the loop example with var and let. Predicting outputs is the fastest way to make the idea stick.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A closure is a function plus the variables it was born next to. Return the function, hand it to a timer or a click handler, and those variables travel with it, privately and reliably. Once you see the backpack, counters, factories, callbacks and even React hooks all start to look like the same friendly idea wearing different clothes.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>closures</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Do You Still Need Antivirus Software in 2026?</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Thu, 12 Nov 2026 07:59:35 +0000</pubDate>
      <link>https://dev.to/kushkrg/do-you-still-need-antivirus-software-in-2026-hcn</link>
      <guid>https://dev.to/kushkrg/do-you-still-need-antivirus-software-in-2026-hcn</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/do-you-need-antivirus-software" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For most Windows users in 2026, the honest answer is: not a separate one. The antivirus built into Windows, Microsoft Defender Antivirus, is a full, always-on security product that updates itself and costs nothing, and for a careful home user it provides protection that would have cost real money a decade ago. Third-party antivirus still makes sense for some people, and this guide explains exactly who, and who can safely save the money.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Changed: Antivirus Grew Up and Moved In
&lt;/h2&gt;

&lt;p&gt;Antivirus used to be a separate purchase because operating systems shipped with nothing. That world is gone. Windows 10 and Windows 11 include Microsoft Defender Antivirus, switched on by default, scanning files in real time, checking downloads, and updating its threat knowledge several times a day through Windows Update. If you install a third-party antivirus, Defender politely steps aside into a limited mode; if you remove it, Defender steps back in. There is no gap where a normal Windows PC runs naked.&lt;/p&gt;

&lt;p&gt;Apple took a different road: macOS includes its own built-in protections (XProtect and Gatekeeper) working silently in the background, and the locked-down design of the system leaves traditional antivirus much less to do. Phones are different again, and we come to them shortly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu49qbdxmmik4mebv78gs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu49qbdxmmik4mebv78gs.png" alt="The Microsoft Support page about virus and threat protection in the Windows Security app" width="799" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Microsoft Support explains the Virus and threat protection page of the Windows Security app, where Microsoft Defender Antivirus settings, scans and ransomware protection live.&lt;/p&gt;

&lt;p&gt;Microsoft's own documentation of the &lt;a href="https://support.microsoft.com/en-us/windows/security/threat-malware-protection/virus-and-threat-protection-in-the-windows-security-app" rel="noopener noreferrer"&gt;Virus and threat protection page in the Windows Security app&lt;/a&gt; lists what the built-in product covers today: current threats and scan options, real-time protection settings, protection updates, and ransomware protection through Controlled Folder Access. That is a proper security suite by any honest measure. Microsoft also sells an upgraded consumer version, described on its &lt;a href="https://www.microsoft.com/en-us/microsoft-365/microsoft-defender-for-individuals" rel="noopener noreferrer"&gt;Microsoft Defender for individuals page&lt;/a&gt;, which adds identity and device monitoring across your phones and computers for Microsoft 365 subscribers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Honest Comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Built-in Defender&lt;/th&gt;
&lt;th&gt;Paid third-party antivirus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Real-time malware protection&lt;/td&gt;
&lt;td&gt;Yes, always on&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Automatic threat updates&lt;/td&gt;
&lt;td&gt;Yes, several times a day&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ransomware folder protection&lt;/td&gt;
&lt;td&gt;Yes (Controlled Folder Access, turn it on)&lt;/td&gt;
&lt;td&gt;Usually yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extra tools (VPN, password manager, identity alerts)&lt;/td&gt;
&lt;td&gt;Limited or separate&lt;/td&gt;
&lt;td&gt;Often bundled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Parental controls and family dashboard&lt;/td&gt;
&lt;td&gt;Basic, via Microsoft Family&lt;/td&gt;
&lt;td&gt;Often stronger&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Free, included with Windows&lt;/td&gt;
&lt;td&gt;Yearly subscription per device&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Effect on speed&lt;/td&gt;
&lt;td&gt;Light, designed for Windows&lt;/td&gt;
&lt;td&gt;Varies; some suites are heavy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Who Can Rely on the Built-In Protection
&lt;/h2&gt;

&lt;p&gt;You are well served by Defender alone if most of this sounds like you: your Windows is genuine and fully updated, you download software from official sources, you do not open strange attachments for fun, and you keep a backup of important files. For this large group, the extra money buys convenience features, not meaningfully stronger core protection. Spend it on a backup drive or a password manager instead; both prevent more real-world pain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who Should Still Consider Paying
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Families with less technical members.&lt;/strong&gt; A single dashboard, one renewal and bundled parental controls can be worth the fee when you are the unpaid IT department for six people.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;People who want the bundle.&lt;/strong&gt; If you would buy a VPN, identity monitoring and a password manager anyway, a suite that includes them can work out cheaper.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Small businesses without IT staff.&lt;/strong&gt; Central management and business-grade support matter when five office PCs hold customer data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anyone on an old, unsupported Windows.&lt;/strong&gt; If your system no longer receives updates, its built-in protection ages too; a maintained third-party product is a partial patch, though replacing the system is the real fix.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What No Antivirus Can Save You From
&lt;/h2&gt;

&lt;p&gt;Antivirus watches for malicious software. It cannot stop you typing your password into a fake bank page, approving a scam payment, or reusing a leaked password. The modern attack is usually a trick played on a person, not a virus dropped on a machine. That is why the layered basics matter more than the brand on your scanner: updates, unique passwords, two-factor authentication, and a firewall checking connections. Our guides on &lt;a href="https://codingcush.com/what-is-malware-types-explained" rel="noopener noreferrer"&gt;what malware is and its main types&lt;/a&gt;, &lt;a href="https://codingcush.com/what-is-ransomware-how-to-protect-yourself" rel="noopener noreferrer"&gt;what ransomware is and how to protect yourself&lt;/a&gt; and &lt;a href="https://codingcush.com/what-is-a-firewall-explained" rel="noopener noreferrer"&gt;what a firewall is and how it protects you&lt;/a&gt; complete that picture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beware the Fake Antivirus: Scareware
&lt;/h2&gt;

&lt;p&gt;There is a special irony in the antivirus world: some of the "antivirus" warnings people see are themselves the attack. Scareware is a fake alert, usually a web page popup or a rogue app, screaming that your device is infected and urging you to call a number or pay for cleaning right now. Real security software never demands instant payment through a popup, and your browser cannot diagnose your computer. If such a warning appears, close the tab (force-quit the browser if it refuses), and never call the number; the friendly "technician" is the criminal. A useful rule: genuine protection works quietly, while scams always shout and hurry you.&lt;/p&gt;

&lt;p&gt;This matters for the buying decision too. If you do shop for a suite, download it only from the maker's official website or your device's official store, type the address yourself, and ignore any "your computer is infected" advert that tries to help you find one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Macs, Phones and the "No Viruses Here" Myth
&lt;/h2&gt;

&lt;p&gt;Macs get malware too; there is simply less of it, and the built-in protections handle the common share. Most Mac users can skip paid antivirus and invest in updates and backups. On phones, iOS does not permit traditional antivirus at all, and Android relies on the built-in Play Protect plus careful installing. If an app store listing promises to "clean and speed up" your phone with flashing warnings, that app is closer to the problem than the solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  And What About Linux?
&lt;/h2&gt;

&lt;p&gt;Linux desktops are a small target with a careful software culture, and most home Linux users sensibly skip traditional antivirus, relying on updates, official repositories and the system's permission model. The exceptions are Linux machines that serve files to Windows computers, where scanning protects the Windows side of the family, and anyone running a mail or file server for others. For a personal Linux laptop, your update habit is the antivirus, and your backup is the insurance, the same recipe as everywhere else in this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is Microsoft Defender really as good as paid antivirus?
&lt;/h3&gt;

&lt;p&gt;In independent lab tests over recent years, Defender's detection scores sit in the same top band as the famous paid names, and it is perfectly integrated with Windows. Paid products compete on extra features, support and bundled tools rather than a large protection gap.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I run two antivirus programs together for extra safety?
&lt;/h3&gt;

&lt;p&gt;No. Two real-time scanners fight over the same files, slow the machine and can confuse each other. Windows handles this sensibly by stepping Defender aside when another antivirus registers, and you should let it.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about free third-party antivirus?
&lt;/h3&gt;

&lt;p&gt;Some are decent, but several famous free products earn their money from bundled extras, upsell popups or data practices you would not choose. If you want free, the built-in Defender is the cleanest free option of all.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I check Defender is actually on?
&lt;/h3&gt;

&lt;p&gt;Open the Windows Security app and look at Virus and threat protection. It should show no actions needed, with real-time protection on. Run a quick scan while you are there, and turn on Controlled Folder Access under ransomware protection for an extra layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Short Version
&lt;/h2&gt;

&lt;p&gt;In 2026, antivirus is not something most people need to buy, because a good one already lives inside Windows and macOS, quietly doing the job. Pay for a third-party suite when its bundle, family controls or business features genuinely serve you, not out of habit or fear. And whichever you choose, remember the scanner is one player on the team: updates, backups, unique passwords and a switched-on firewall win more matches than any brand name ever could.&lt;/p&gt;

</description>
      <category>antivirus</category>
      <category>windows</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>How to Protect Your Phone from Hackers: 10 Simple Steps</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Thu, 12 Nov 2026 07:58:48 +0000</pubDate>
      <link>https://dev.to/kushkrg/how-to-protect-your-phone-from-hackers-10-simple-steps-42o2</link>
      <guid>https://dev.to/kushkrg/how-to-protect-your-phone-from-hackers-10-simple-steps-42o2</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/how-to-protect-your-phone-from-hackers" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Your phone holds your bank, your photos, your messages and the keys to almost every account you own, which makes it the single most valuable target a hacker can pick. The good news: phones are genuinely hard to break into when their built-in protections are switched on. These 10 simple steps, most of them one-time settings, turn your phone from an easy target into a frustrating one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Phones Get Hacked (It Is Rarely Magic)
&lt;/h2&gt;

&lt;p&gt;Real phone hacks usually begin with something ordinary: a fake app, a tricked permission, a password reused from an old leak, or a system update ignored for months. Remote super-hacks that take over a phone from thin air exist, but they are rare and expensive, aimed at very specific people. For the rest of us, boring habits beat exotic attacks. Here is the routine that covers you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 10 Steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Use a strong screen lock, and your face or finger
&lt;/h3&gt;

&lt;p&gt;Set a PIN of at least six digits, or a proper passphrase, and turn on fingerprint or face unlock so you actually use the lock every time. A phone that locks in 30 seconds is a phone a thief cannot browse.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Install updates the day they arrive
&lt;/h3&gt;

&lt;p&gt;Updates are not feature adverts; they are repairs for holes that criminals actively use. Turn on automatic updates for the system and your apps, and let the phone do its quiet night-time patching.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Only install apps from the official store
&lt;/h3&gt;

&lt;p&gt;The Play Store and App Store are not perfect, but they check apps in a way random download sites never will. Most phone infections arrive dressed as a free game, a video downloader or a cracked app from outside the store. Our guide on &lt;a href="https://codingcush.com/what-is-malware-types-explained" rel="noopener noreferrer"&gt;what malware is and its main types&lt;/a&gt; shows the costumes these programs wear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Review app permissions like a strict landlord
&lt;/h3&gt;

&lt;p&gt;Once a month, open the permissions screen and ask hard questions. Why does a torch app need your contacts? Why does a game need your location at all times? Revoke what makes no sense; honest apps keep working.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Turn on two-factor authentication for your main accounts
&lt;/h3&gt;

&lt;p&gt;Email first, then banking, then social media. If your Google, Apple or email account falls, password resets for everything else follow it down like dominoes. Protect the account that protects the others.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Upgrade your logins to passkeys where offered
&lt;/h3&gt;

&lt;p&gt;A passkey replaces the password with a cryptographic key stored on your phone, unlocked by your face or finger, and it cannot be phished or reused. Our guide on &lt;a href="https://codingcush.com/what-is-a-passkey-how-to-set-it-up" rel="noopener noreferrer"&gt;what a passkey is and how to set it up&lt;/a&gt; takes you through it in minutes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Turn on Find My Device and remote wipe
&lt;/h3&gt;

&lt;p&gt;Google and Apple both offer free tools to locate a lost phone, lock it, show a contact message on its screen, or erase it completely. Set this up while the phone is still safely in your hand, not after it vanishes into a taxi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fau1p9jf6uxxlk5uug3e3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fau1p9jf6uxxlk5uug3e3.png" alt="The Google Safety Center homepage on safety.google" width="799" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Google Safety Center (safety.google) gathers the safety and privacy controls for Google accounts and Android devices in one place.&lt;/p&gt;

&lt;p&gt;Google collects its account and device protections in the &lt;a href="https://safety.google/" rel="noopener noreferrer"&gt;Google Safety Center at safety.google&lt;/a&gt;, a useful page to browse once with a cup of tea. Apple publishes its side of the story on its &lt;a href="https://www.apple.com/privacy/" rel="noopener noreferrer"&gt;official privacy pages at apple.com&lt;/a&gt;, including how iPhone permissions and tracking controls work. Ten minutes on your own platform's page teaches you where every switch lives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 8: Be suspicious of links in messages
&lt;/h3&gt;

&lt;p&gt;Delivery scams, bank warnings and prize messages all want one tap. The rules are simple: unexpected link plus urgency equals delete. Open your bank's app directly instead of following any link a message gives you.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 9: Treat public Wi-Fi and charging points with care
&lt;/h3&gt;

&lt;p&gt;On shared networks, keep money matters for your mobile data, and carry your own charger and cable rather than trusting a stranger's USB port. Our 9 rules for &lt;a href="https://codingcush.com/how-to-stay-safe-on-public-wifi" rel="noopener noreferrer"&gt;how to stay safe on public Wi-Fi&lt;/a&gt; cover the network side in full.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 10: Back up your phone, automatically
&lt;/h3&gt;

&lt;p&gt;A backup turns a lost, stolen or broken phone from a catastrophe into an inconvenience. Turn on automatic cloud backup for photos and app data, and check once that it really is running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Signs Your Phone May Already Have a Problem
&lt;/h2&gt;

&lt;p&gt;Most compromises whisper rather than shout. Watch for a battery that suddenly drains by lunch, a phone that runs hot while doing nothing, data usage you cannot explain, apps you do not remember installing, or friends receiving strange messages from your accounts. Any one of these can have an innocent cause, but two or three together deserve action: update everything, uninstall unfamiliar apps, change your main account passwords from a clean device, and run the built-in security check your phone offers. If money apps are involved, call the bank and tell them plainly what you found.&lt;/p&gt;

&lt;p&gt;A special word for work phones and phones that double as work phones: if your employer manages the device, tell IT early rather than quietly trying fixes yourself. They have tools to see what happened across the whole system, and a fast report protects your colleagues as well as you. There is no shame in being tricked; the only real mistake is staying silent while the problem grows.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Five-Minute Weekly Habit
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Quick check&lt;/th&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;th&gt;Time needed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Any updates waiting?&lt;/td&gt;
&lt;td&gt;Settings, system update&lt;/td&gt;
&lt;td&gt;1 minute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Any new apps you do not remember?&lt;/td&gt;
&lt;td&gt;App drawer or library&lt;/td&gt;
&lt;td&gt;1 minute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Permissions still sensible?&lt;/td&gt;
&lt;td&gt;Settings, privacy, permissions&lt;/td&gt;
&lt;td&gt;2 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backup ran recently?&lt;/td&gt;
&lt;td&gt;Settings, backup&lt;/td&gt;
&lt;td&gt;1 minute&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  A Note on Second-Hand and Handed-Down Phones
&lt;/h2&gt;

&lt;p&gt;Buying a used phone, or passing yours to a family member, deserves five careful minutes. The previous owner's accounts, backups and Find My Device links must be fully removed, ideally with a factory reset done together at the time of sale. A phone still signed into a stranger's account can be tracked, locked or wiped by that person, and a phone you sell without resetting it hands your photos and logins to its new owner. When you receive a used phone, reset it yourself before adding anything, install the latest update it supports, and only then make it yours.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Do I need an antivirus app on my phone?
&lt;/h3&gt;

&lt;p&gt;On iPhone, no; the system does not allow traditional antivirus and does not need it. On Android, the built-in Play Protect plus the habits above are enough for most people. A reputable security app is optional, never a substitute for updates and careful installs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can someone hack my phone just by calling me?
&lt;/h3&gt;

&lt;p&gt;For ordinary users, no. A call alone cannot install anything. What calls can do is trick you into sharing codes or details, which is a scam, not a hack, and the defence is to never share a code with anyone, ever.&lt;/p&gt;

&lt;h3&gt;
  
  
  My phone is old and no longer gets updates. Is it still safe?
&lt;/h3&gt;

&lt;p&gt;Honestly, its risk grows every month, because new holes stop being repaired. If it holds your banking and email, plan an upgrade to a model still receiving updates, and until then avoid installing new apps from anywhere but the official store.&lt;/p&gt;

&lt;h3&gt;
  
  
  Someone sent me a strange configuration profile or app link. What should I do?
&lt;/h3&gt;

&lt;p&gt;Do not install it. Profiles and apps sent by message, however official the message looks, are a classic route in. If your bank or employer genuinely needs you to install something, they will happily confirm it through their official app or website.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Short Version
&lt;/h2&gt;

&lt;p&gt;Lock the screen properly, update on day one, install only from the official store, and keep permissions on a short leash. Add two-factor authentication, passkeys, Find My Device and an automatic backup, and your phone becomes a hard, unrewarding target. None of this costs money, and most of it is set once and forgotten, which is exactly how good security should feel.&lt;/p&gt;

</description>
      <category>android</category>
      <category>iphone</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>What Is a Data Breach? What to Do If Your Data Leaks</title>
      <dc:creator>Lavkush Kumar</dc:creator>
      <pubDate>Thu, 12 Nov 2026 07:58:02 +0000</pubDate>
      <link>https://dev.to/kushkrg/what-is-a-data-breach-what-to-do-if-your-data-leaks-2gbl</link>
      <guid>https://dev.to/kushkrg/what-is-a-data-breach-what-to-do-if-your-data-leaks-2gbl</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://codingcush.com/what-is-a-data-breach-what-to-do" rel="noopener noreferrer"&gt;CodingCush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A data breach is when private information stored by a company or service gets out to people who should never have it: copied by criminals, exposed by a mistake, or sold onward to scammers. Names, emails, passwords, phone numbers and even card details can leak. The breach is the company's problem, but the clean-up quickly becomes yours, so knowing the calm, correct steps matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Breaches Usually Happen
&lt;/h2&gt;

&lt;p&gt;Breaches are rarely the movie scene of a genius typing furiously. The common causes are much duller, which makes them more dangerous, because they happen all the time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stolen or guessed passwords&lt;/strong&gt; on a company system, giving attackers the keys rather than forcing them to pick the lock.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unpatched software&lt;/strong&gt;: a known hole that a fix existed for, left open too long.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A staff member tricked&lt;/strong&gt; by a phishing message into handing over access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A misconfigured database&lt;/strong&gt; left open to the internet by accident, with no attack needed at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A lost or stolen laptop or drive&lt;/strong&gt; full of customer records.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once inside, criminals copy the database and leave. The data then gets traded in criminal marketplaces, sometimes for years, and feeds waves of phishing emails, scam calls and identity theft attempts long after the headlines fade.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Types of Data That Leak, and Why Each One Matters
&lt;/h2&gt;

&lt;p&gt;Not all leaked data is equal. Knowing what escaped tells you how seriously to react:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Email addresses alone&lt;/strong&gt; mostly mean more spam and phishing aimed at you. Annoying, but manageable with a good spam filter and a suspicious eye.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Passwords&lt;/strong&gt; are the dangerous ones, especially if you reuse them. Attackers automatically try leaked email and password pairs on banking, shopping and email sites, a technique called credential stuffing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Names, addresses and dates of birth&lt;/strong&gt; are the building blocks of identity theft and convincing scam calls, because they let a stranger sound like they know you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phone numbers&lt;/strong&gt; invite scam calls, SIM swap attempts and password reset attacks on accounts that use text message codes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payment card details&lt;/strong&gt; need the fastest response: tell the bank, watch statements, and expect a replacement card.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private messages, photos or documents&lt;/strong&gt; are rare in big breaches but the most personal, and can be used for embarrassment or blackmail. Treat any such approach as a crime and report it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read any breach notice with this list beside you. "Email addresses only" and "email addresses plus passwords" are different emergencies wearing similar clothes.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Check Whether Your Data Has Leaked
&lt;/h2&gt;

&lt;p&gt;You do not have to wait for a letter. Free services collect known breach data and let you check your own email address safely. Our step-by-step guide on &lt;a href="https://codingcush.com/how-to-check-if-your-email-was-hacked" rel="noopener noreferrer"&gt;how to check if your email was hacked&lt;/a&gt; walks through the process, and the best known checker is &lt;a href="https://haveibeenpwned.com/" rel="noopener noreferrer"&gt;Have I Been Pwned&lt;/a&gt;, a respected free service run by security researcher Troy Hunt, holding records from thousands of breaches. Run your email address through it today; the answer takes seconds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb7ifl8qfarfkluxpiah6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb7ifl8qfarfkluxpiah6.png" alt="The Mozilla Monitor homepage on monitor.mozilla.org, a free data breach checking service" width="799" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mozilla Monitor (monitor.mozilla.org) scans known data breaches to see if your email address and private information have been exposed, and suggests steps to fix it.&lt;/p&gt;

&lt;p&gt;Another free option, visible in the screenshot above, is Mozilla Monitor, which scans breach data for your email and explains what each leak contained. Whichever checker you use, treat the result as useful information, not a disaster notice. Finding your email in an old breach is extremely common, and the fixes below are the same either way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Action Plan: What to Do in the First 24 Hours
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Change the password on the breached account&lt;/strong&gt;, and make the new one long, unique and never used anywhere else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change the same password anywhere else you reused it.&lt;/strong&gt; Reuse is how one leak becomes ten takeovers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn on two-factor authentication&lt;/strong&gt; for that account and your email. Our explainer on &lt;a href="https://codingcush.com/what-is-two-factor-authentication" rel="noopener noreferrer"&gt;what two-factor authentication is&lt;/a&gt; shows the options, from codes to security keys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch for follow-up scams.&lt;/strong&gt; Criminals use leaked details to make phishing messages scarily personal. A message that knows your name and an old password is still a scam if it rushes you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check your bank and card statements&lt;/strong&gt; if any financial detail was involved, and tell your bank early; they can watch or replace cards.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Save the breach notification&lt;/strong&gt; and note what data was exposed. You may need it if problems appear months later.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the breach leads to actual identity theft, official help exists: the United States Federal Trade Commission runs &lt;a href="https://www.identitytheft.gov/" rel="noopener noreferrer"&gt;IdentityTheft.gov&lt;/a&gt;, which builds a personal recovery plan and the letters you need, free of charge. Readers in other countries will find similar reporting routes through their national consumer or police portals.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Companies Are Supposed to Do (and Why You Hear Late)
&lt;/h2&gt;

&lt;p&gt;In many places the law now requires companies to report serious breaches to a regulator quickly (in the European Union, within 72 hours of becoming aware) and to inform affected customers without undue delay when the risk to them is high. India's data protection law likewise requires notification to the Data Protection Board and to affected users. Companies sometimes take weeks to tell customers because they must first confirm what happened and work with investigators, and criminals occasionally announce the stolen data before the company does. The lesson for you is simple: do not wait for permission to protect yourself. The moment you hear a service you use has leaked, run the action plan above.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Quiet Hero: Encryption Limits the Damage
&lt;/h2&gt;

&lt;p&gt;There is one piece of good news inside many breach stories. If the stolen data was properly encrypted, the criminals may hold nothing but scrambled nonsense. This is why our explainer on &lt;a href="https://codingcush.com/what-is-encryption-explained-simply" rel="noopener noreferrer"&gt;what encryption is and how it keeps your data safe&lt;/a&gt; matters beyond messaging apps: it is also the reason some breaches end with an apology and no real harm, while others, where passwords were stored carelessly, turn into years of scam attempts. When a breach notice says passwords were "hashed and salted", that is the fingerprint method described there, and it is a much better sign than passwords stored in plain text.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Long Does Leaked Data Stay Dangerous?
&lt;/h2&gt;

&lt;p&gt;Longer than feels fair. Email addresses and names never expire, passwords stay useful until you change them, and dates of birth are permanent. Criminals know this, and old breach collections are bundled together and resold for years, which is why a scam in 2026 can quote details from a leak in 2021. The hopeful side of the same fact: the moment you change a password and add two-factor protection, that copy of your data starts rotting. Stolen information has a shelf life, and your habits decide how short it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Will a company always tell me if my data leaked?
&lt;/h3&gt;

&lt;p&gt;Not always. Laws in many regions require notification for serious breaches, but small incidents, old breaches discovered years later, and data traded quietly can slip past. Checking your email on a breach checker once or twice a year is a sensible habit.&lt;/p&gt;

&lt;h3&gt;
  
  
  My email is in a breach from years ago. Should I worry?
&lt;/h3&gt;

&lt;p&gt;Worry is not needed; action is. If you have since changed that password and never reused it, the old leak is mostly history. If the password still protects anything today, change it now and turn on two-factor authentication.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I delete my data from the internet after a breach?
&lt;/h3&gt;

&lt;p&gt;Honestly, no. Once data is copied and traded, there is no recall button. What you can do is make the leaked data useless: new unique passwords, two-factor everywhere, and suspicion toward messages that quote your old details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I pay for a dark web monitoring service?
&lt;/h3&gt;

&lt;p&gt;For most people, the free checkers plus the action plan above cover the real risks. Paid monitoring mostly watches the same sources. Spend the money on a good password manager instead; it prevents far more damage.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Short Version
&lt;/h2&gt;

&lt;p&gt;A data breach means a service lost control of private information, and copies may circulate for years. Check your email on a free breach checker, change and never reuse the affected passwords, turn on two-factor authentication, and stay alert for personalised scams that quote your leaked details. You cannot undo a leak, but you can absolutely make the leaked data worthless. That is a good day's work, and it starts with one password change.&lt;/p&gt;

</description>
      <category>databreach</category>
      <category>cybersecurity</category>
      <category>privacy</category>
      <category>security</category>
    </item>
  </channel>
</rss>
