<?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: Neha Christina</title>
    <description>The latest articles on DEV Community by Neha Christina (@neha_christina_1ac8651819).</description>
    <link>https://dev.to/neha_christina_1ac8651819</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3809390%2Fc2a6f0e9-4e87-436c-9536-9d1201ba2541.PNG</url>
      <title>DEV Community: Neha Christina</title>
      <link>https://dev.to/neha_christina_1ac8651819</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/neha_christina_1ac8651819"/>
    <language>en</language>
    <item>
      <title>CTEs vs Subqueries in SQL: Which One Should You Use?</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Thu, 02 Apr 2026 10:44:25 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/ctes-vs-subqueries-in-sql-which-one-should-you-use-3p4e</link>
      <guid>https://dev.to/neha_christina_1ac8651819/ctes-vs-subqueries-in-sql-which-one-should-you-use-3p4e</guid>
      <description>&lt;p&gt;If you've written SQL for more than a week, you've hit this question.&lt;/p&gt;

&lt;p&gt;Do I use a CTE or a subquery here?&lt;/p&gt;

&lt;p&gt;Both can solve the same problem. Both produce the same result. So which one is actually better?&lt;/p&gt;

&lt;p&gt;The honest answer: it depends. But there are clear rules for when to use each — and once you know them, you'll never second-guess yourself again.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Subquery?
&lt;/h2&gt;

&lt;p&gt;A subquery is a query nested inside another query. It runs inline, right where it's written.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="c1"&gt;-- This is the subquery&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The inner &lt;code&gt;SELECT AVG(salary)&lt;/code&gt; runs first, produces a single value, and the outer query uses that value in its &lt;code&gt;WHERE&lt;/code&gt; clause.&lt;/p&gt;

&lt;p&gt;Subqueries can live in &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;FROM&lt;/code&gt;, &lt;code&gt;WHERE&lt;/code&gt;, and &lt;code&gt;HAVING&lt;/code&gt; clauses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Quick to write for simple filters. No extra syntax needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; Gets hard to read when nested more than one level deep. Can't reuse the result elsewhere in the same query.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a CTE?
&lt;/h2&gt;

&lt;p&gt;A CTE (Common Table Expression) is a named temporary result set defined at the top of your query using &lt;code&gt;WITH … AS ()&lt;/code&gt;. You reference it by name below — just like a real table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Define the CTE first&lt;/span&gt;
&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;-- Now use it like a table&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&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;avg_sal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CTE is defined once at the top and can be referenced multiple times in the main query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Very readable — complex logic is broken into named steps. Can be referenced more than once within the same query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; Slightly more verbose. Not all databases support recursive CTEs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Same Query, Two Ways
&lt;/h2&gt;

&lt;p&gt;Here's the same problem — find employees earning above the average salary — written both ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subquery version:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CTE version:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="k"&gt;avg&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&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="k"&gt;avg&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same result. Different readability. The CTE version makes the intent clearer — especially as queries get more complex.&lt;/p&gt;




&lt;h2&gt;
  
  
  When to Use a Subquery
&lt;/h2&gt;

&lt;p&gt;Use a subquery when the logic is simple and short, you only need it in one place, and you're filtering in &lt;code&gt;WHERE&lt;/code&gt; or &lt;code&gt;HAVING&lt;/code&gt;. For quick one-liners, subqueries are perfectly fine.&lt;/p&gt;




&lt;h2&gt;
  
  
  When to Use a CTE
&lt;/h2&gt;

&lt;p&gt;Use a CTE when you need to reference the result more than once, the query is complex and needs to be readable, or you're building step-by-step transformations where each step builds on the last.&lt;/p&gt;

&lt;p&gt;CTEs are especially powerful when chained together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt;
&lt;span class="n"&gt;step_one&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
  &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;
&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="n"&gt;step_two&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;step_one&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;70000&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;step_two&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each CTE becomes a building block. Much easier to debug than deeply nested subqueries.&lt;/p&gt;




&lt;h2&gt;
  
  
  Do CTEs Run Faster?
&lt;/h2&gt;

&lt;p&gt;This is the question most people get wrong.&lt;/p&gt;

&lt;p&gt;In most modern databases — including Snowflake and BigQuery — the query optimiser treats CTEs and subqueries almost identically. Neither is consistently faster.&lt;/p&gt;

&lt;p&gt;The exception: older versions of Redshift and PostgreSQL sometimes materialise CTEs (compute them separately and store the result), which can make CTEs slower for complex queries. If you're on one of these, test both and measure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The real rule:&lt;/strong&gt; optimise for readability first. Only swap to subqueries for performance if you've actually measured a difference.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cheat Sheet
&lt;/h2&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;Subquery&lt;/th&gt;
&lt;th&gt;CTE&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Syntax&lt;/td&gt;
&lt;td&gt;Inline&lt;/td&gt;
&lt;td&gt;&lt;code&gt;WITH … AS ()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Gets messy&lt;/td&gt;
&lt;td&gt;Very readable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reuse in query?&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Same&lt;/td&gt;
&lt;td&gt;Same*&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recursive?&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Simple filters&lt;/td&gt;
&lt;td&gt;Complex logic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;*Performance varies by database — always test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note on reusability:&lt;/strong&gt; A CTE can be referenced multiple times within the single query it's defined in. It does not persist across queries — for that you'd need a temporary table or a view.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Simple Decision Rule
&lt;/h2&gt;

&lt;p&gt;If the logic fits in 2–3 lines and you only need it once → subquery.&lt;/p&gt;

&lt;p&gt;If the logic is complex, reused, or needs to be understood by someone else → CTE.&lt;/p&gt;

&lt;p&gt;When in doubt, use a CTE. Readability is worth more than brevity in team environments.&lt;/p&gt;




&lt;p&gt;Which do YOU prefer — CTEs or subqueries? Drop a comment below 👇&lt;/p&gt;

&lt;p&gt;Follow me on Instagram at &lt;a href="https://www.instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://www.instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python and Snowflake tips every week 💙&lt;/p&gt;

</description>
      <category>sql</category>
      <category>dataengineering</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>5 Python Built-ins You’re Not Using (But Should Be)</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Fri, 27 Mar 2026 18:36:43 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/5-python-built-ins-youre-not-using-but-should-be-930</link>
      <guid>https://dev.to/neha_christina_1ac8651819/5-python-built-ins-youre-not-using-but-should-be-930</guid>
      <description>&lt;p&gt;You don’t need a library. You don’t need to &lt;code&gt;pip install&lt;/code&gt; anything. These five tools are already sitting inside Python, waiting for you to use them.&lt;/p&gt;

&lt;p&gt;Most junior developers don’t know they exist. Senior developers reach for them every single day.&lt;/p&gt;

&lt;p&gt;Let’s fix that.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. zip()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Loop over multiple lists at the same time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How most beginners do it:&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;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Alice&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Bob&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Carol&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;87&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;92&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="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;names&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="n"&gt;scores&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How you should do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;zip()&lt;/code&gt; pairs up elements from two (or more) iterables and lets you loop over them together. It stops when the shortest one runs out.&lt;/p&gt;

&lt;p&gt;You can also use it to combine lists into a dictionary:&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;name_score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# {'Alice': 95, 'Bob': 87, 'Carol': 92}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. any() and all()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Check conditions across a list without writing a loop.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The verbose way:&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;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;92&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;78&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;has_pass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;scores&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;s&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;has_pass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The clean way:&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;has_pass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;all_pass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;any()&lt;/code&gt; returns &lt;code&gt;True&lt;/code&gt; if at least one item meets the condition. &lt;code&gt;all()&lt;/code&gt; returns &lt;code&gt;True&lt;/code&gt; only if every item does. Both short-circuit — they stop checking as soon as the answer is known, which makes them fast.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. enumerate()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Get the index AND value without range(len()).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The clunky version:&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;fruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;apple&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;banana&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cherry&lt;/span&gt;&lt;span class="sh"&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;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruits&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Pythonic version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruit&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to start counting from 1 instead of 0?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruit&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&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;print&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="n"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;range(len())&lt;/code&gt; is considered a code smell in Python. If you find yourself writing it, reach for &lt;code&gt;enumerate()&lt;/code&gt; instead.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. map()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Apply a function to every item in a list.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The loop version:&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;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;alice&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bob&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;carol&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;capitalised&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;capitalised&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;map()&lt;/code&gt;:&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;capitalised&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or with a lambda for custom logic:&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;doubled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&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="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;map()&lt;/code&gt; is great for simple, single-function transformations. For more complex logic involving conditions or multiple steps, a list comprehension is usually more readable:&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;capitalised&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&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;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both are valid — pick whichever reads more clearly for your use case.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. collections
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Counter, defaultdict, deque — all built in.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The manual counting approach:&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;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cat&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dog&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cat&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bird&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cat&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&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;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;words&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;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;Counter&lt;/code&gt;:&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="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;

&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Counter({'cat': 3, 'dog': 1, 'bird': 1})
&lt;/span&gt;
&lt;span class="n"&gt;top_2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;most_common&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="c1"&gt;# [('cat', 3), ('dog', 1)]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;collections&lt;/code&gt; also gives you:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;defaultdict&lt;/strong&gt; — like a regular dict, but never raises a &lt;code&gt;KeyError&lt;/code&gt;. Automatically creates a default value for missing keys.&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="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;defaultdict&lt;/span&gt;
&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;missing&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;append&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="c1"&gt;# No KeyError!
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;deque&lt;/strong&gt; — a double-ended queue. Much faster than a list for appending or popping from both ends.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;namedtuple&lt;/strong&gt; — a tuple where you can access items by name instead of index.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cheat Sheet
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Built-in&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;When to use it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;zip()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pairs up multiple iterables&lt;/td&gt;
&lt;td&gt;Looping over two lists together&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;any()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;True if at least one item passes&lt;/td&gt;
&lt;td&gt;Checking if any condition is met&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;all()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;True if every item passes&lt;/td&gt;
&lt;td&gt;Validating a whole list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;enumerate()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gives index + value&lt;/td&gt;
&lt;td&gt;When you need both in a loop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Applies a function to each item&lt;/td&gt;
&lt;td&gt;Simple transformations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Counter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Counts occurrences&lt;/td&gt;
&lt;td&gt;Frequency analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;defaultdict&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Dict with default values&lt;/td&gt;
&lt;td&gt;Avoiding KeyErrors&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The Key Takeaway
&lt;/h2&gt;

&lt;p&gt;None of these require installing anything. They’re all part of Python’s standard library, designed specifically for the problems you solve every day.&lt;/p&gt;

&lt;p&gt;The difference between a junior and senior Python developer often isn’t the complex stuff — it’s knowing these small tools exist and reaching for them instead of writing loops from scratch.&lt;/p&gt;




&lt;p&gt;Which one did you NOT know about before reading this? Comment below 👇&lt;/p&gt;

&lt;p&gt;Follow me on Instagram at &lt;a href="https://www.instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://www.instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python and Snowflake tips every week 💚&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>A Day in the Life of a Data Engineer (Real Talk, No Filter)</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Tue, 24 Mar 2026 11:15:14 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/a-day-in-the-life-of-a-data-engineer-real-talk-no-filter-18cm</link>
      <guid>https://dev.to/neha_christina_1ac8651819/a-day-in-the-life-of-a-data-engineer-real-talk-no-filter-18cm</guid>
      <description>&lt;p&gt;If you've ever wondered what data engineers actually do all day — this one's for you.&lt;/p&gt;

&lt;p&gt;Not the LinkedIn version. The real version.&lt;/p&gt;

&lt;p&gt;I've been in tech for 10+ years and I still get asked "so what do you actually &lt;em&gt;do&lt;/em&gt;?" at family dinners. This post is my answer.&lt;/p&gt;




&lt;h2&gt;
  
  
  9:00 AM — Standup &amp;amp; Morning Triage
&lt;/h2&gt;

&lt;p&gt;First thing I do is &lt;strong&gt;not&lt;/strong&gt; open Slack.&lt;/p&gt;

&lt;p&gt;I open my monitoring dashboard.&lt;/p&gt;

&lt;p&gt;Most pipeline failures happen overnight while nobody's watching. If something broke at 3am, I want to know before the business analyst in another timezone notices their dashboard is showing yesterday's data.&lt;/p&gt;

&lt;p&gt;Once I've checked the alerts I jump into standup. Ours is 15 minutes max. What did I do yesterday, what am I doing today, what's blocking me. That's it.&lt;/p&gt;

&lt;p&gt;Then I triage tickets. Some days I have three things to do. Some days I have fifteen. Prioritising is a skill they don't teach you in bootcamp but you learn fast.&lt;/p&gt;




&lt;h2&gt;
  
  
  9:30 AM — Pipeline Review
&lt;/h2&gt;

&lt;p&gt;This is the unglamorous part of the job that nobody talks about.&lt;/p&gt;

&lt;p&gt;Every morning I check whether last night's ETL jobs completed successfully. Did the data land in Snowflake? Are the row counts what we'd expect? Did any data quality checks fail?&lt;/p&gt;

&lt;p&gt;If something broke, I investigate. This means reading logs, checking error messages, and tracing back through the pipeline to find where it fell over. Sometimes it's a network timeout. Sometimes it's a schema change upstream that nobody told us about. Sometimes it's my own code from two weeks ago coming back to bite me.&lt;/p&gt;

&lt;p&gt;Most pipeline fires happen overnight. Mornings are for damage control before anyone notices.&lt;/p&gt;




&lt;h2&gt;
  
  
  11:00 AM — Deep Work (Headphones On)
&lt;/h2&gt;

&lt;p&gt;This is my favourite part of the day.&lt;/p&gt;

&lt;p&gt;I block this time aggressively. No meetings if I can help it. Headphones on. Do Not Disturb on. This is when actual building happens.&lt;/p&gt;

&lt;p&gt;What does building look like?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing Python ETL scripts.&lt;/strong&gt; Reading data from an API, transforming it, loading it into Snowflake. Handling edge cases. Writing tests so future-me doesn't break it accidentally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building SQL transformations.&lt;/strong&gt; Using dbt to model data in the warehouse — turning raw event data into clean, business-friendly tables that analysts can actually use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debugging.&lt;/strong&gt; Always debugging. Something that worked last week mysteriously doesn't work today. This is the job.&lt;/p&gt;




&lt;h2&gt;
  
  
  12:30 PM — Code Review
&lt;/h2&gt;

&lt;p&gt;Before I eat lunch I try to clear my code review queue.&lt;/p&gt;

&lt;p&gt;Code review is one of the most valuable things a senior engineer can do for a team. Reading someone else's PR carefully, leaving a thoughtful comment, catching a bug before it hits production — that's real impact.&lt;/p&gt;

&lt;p&gt;I also get my own code reviewed. Fresh eyes catch things you're blind to after staring at the same function for two hours.&lt;/p&gt;




&lt;h2&gt;
  
  
  2:00 PM — Stakeholder Meetings
&lt;/h2&gt;

&lt;p&gt;Yes, data engineers go to meetings. A lot of them.&lt;/p&gt;

&lt;p&gt;The afternoon tends to be meeting-heavy. This might be a sync with the data analytics team to tell them a new dataset is ready. It might be a session with a product manager to understand the business requirements for a new pipeline. It might be a cross-team call about an upcoming data model change that'll affect three different teams.&lt;/p&gt;

&lt;p&gt;The best data engineers I've worked with are great communicators. They can explain a technical concept to a non-technical stakeholder without talking down to them. That skill is worth as much as knowing Python.&lt;/p&gt;




&lt;h2&gt;
  
  
  3:30 PM — Documentation &amp;amp; Mentoring
&lt;/h2&gt;

&lt;p&gt;Nobody loves writing documentation but everyone loves finding it when they need it.&lt;/p&gt;

&lt;p&gt;I try to keep a rule: if I build it, I document it. What does it do, where does the data come from, what should you do if it breaks. Future me and my teammates will thank present me.&lt;/p&gt;

&lt;p&gt;This slot also tends to be when junior engineers come to me with questions. Debugging sessions, code reviews, architecture questions. I was that junior engineer once. Paying it forward matters.&lt;/p&gt;




&lt;h2&gt;
  
  
  4:00 PM — Wrap Up
&lt;/h2&gt;

&lt;p&gt;The last hour is for closing out.&lt;/p&gt;

&lt;p&gt;I look at my ticket list. What did I actually complete today? What's moving to tomorrow? Are there any overnight jobs I need to leave notes about?&lt;/p&gt;

&lt;p&gt;I clear my Slack backlog — not the other way around. Slack is not a real-time obligation. I check it a few times a day, not constantly.&lt;/p&gt;




&lt;h2&gt;
  
  
  4:30 PM — Learning Time (Protected)
&lt;/h2&gt;

&lt;p&gt;This is the 30 minutes most people skip and then wonder why they feel stuck.&lt;/p&gt;

&lt;p&gt;I keep this time for growth. Reading a technical blog post. Watching a conference talk. Experimenting with a new Snowflake feature. Trying out a new Python library.&lt;/p&gt;

&lt;p&gt;The data engineering landscape changes fast. If you're not learning you're falling behind.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Tech Stack
&lt;/h2&gt;

&lt;p&gt;Here's what I actually use every day:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Snowflake&lt;/strong&gt; — cloud data warehouse, where most of our data lives and gets queried.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; — ETL scripts, data transformation, automation, anything that needs logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitLab&lt;/strong&gt; — CI/CD pipelines, version control and deployments. Every pipeline change is tracked, reviewed and deployed through GitLab. (You'll see Apache Airflow in a lot of job listings for this role — GitLab is what we use at my company, but Airflow is worth learning too.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git / GitHub&lt;/strong&gt; — version control for everything. Every change tracked, every deployment reviewed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dbt&lt;/strong&gt; — transforms raw data inside Snowflake using SQL. Makes data modelling collaborative and testable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Slack&lt;/strong&gt; — where everything actually happens. For better or worse.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Honest Truth Nobody Tells You
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;60% of the job is debugging pipelines that worked yesterday.&lt;/strong&gt; The other 40% is writing the pipelines that will break tomorrow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Communication skills matter as much as coding skills.&lt;/strong&gt; You can write the most elegant Python in the world but if you can't explain your data model to a product manager, you'll be invisible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You'll never stop learning.&lt;/strong&gt; The tools change every year. That's frustrating and exciting at the same time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boring days are good days.&lt;/strong&gt; A day where nothing breaks, all pipelines run, and you shipped one clean PR is a successful day. Don't let anyone tell you otherwise.&lt;/p&gt;




&lt;h2&gt;
  
  
  Want to Become a Data Engineer?
&lt;/h2&gt;

&lt;p&gt;Start with SQL. Then learn Python. Then learn one cloud data warehouse — BigQuery has the most generous free tier if you want to experiment without spending money.&lt;/p&gt;

&lt;p&gt;The path is clearer than it looks from the outside.&lt;/p&gt;




&lt;p&gt;Drop a 🙋 in the comments if you're on your way in — I'd love to know where you're starting from 👇&lt;/p&gt;

&lt;p&gt;Follow me on Instagram at &lt;a href="https://www.instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://www.instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python and Snowflake tips every week 💙&lt;/p&gt;

</description>
      <category>dataengineering</category>
      <category>career</category>
      <category>beginners</category>
      <category>sql</category>
    </item>
    <item>
      <title>Snowflake vs Redshift vs BigQuery: Which One Should You Use?</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Sat, 21 Mar 2026 03:44:27 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/snowflake-vs-redshift-vs-bigquery-which-one-should-you-use-52jf</link>
      <guid>https://dev.to/neha_christina_1ac8651819/snowflake-vs-redshift-vs-bigquery-which-one-should-you-use-52jf</guid>
      <description>&lt;p&gt;If you’ve ever Googled “which cloud data warehouse should I use” and ended up more confused than when you started — this post is for you.&lt;/p&gt;

&lt;p&gt;Snowflake, Redshift, and BigQuery are the three biggest names in cloud data warehousing right now. They all do similar things. They all use SQL. They all run in the cloud. So how do you choose?&lt;/p&gt;

&lt;p&gt;The answer depends on your situation. Let’s break it down.&lt;/p&gt;




&lt;h2&gt;
  
  
  What They All Have in Common
&lt;/h2&gt;

&lt;p&gt;Before the differences, here’s what all three share:&lt;/p&gt;

&lt;p&gt;They store massive amounts of data — we’re talking billions of rows — and let you query it with standard SQL. They all run entirely in the cloud, so there are no servers to buy or maintain. And they’re all used by major companies at scale.&lt;/p&gt;

&lt;p&gt;The differences come down to three things: &lt;strong&gt;cost model&lt;/strong&gt;, &lt;strong&gt;ecosystem&lt;/strong&gt;, and &lt;strong&gt;who they’re built for&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ❄️ Snowflake
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The cloud-agnostic powerhouse.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Snowflake is unique because it runs on AWS, Azure, AND Google Cloud. No other major data warehouse does this. That means if your company uses multiple clouds — or might switch clouds in the future — Snowflake gives you flexibility nobody else does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What makes Snowflake stand out:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Separation of storage and compute.&lt;/strong&gt; This is Snowflake’s key architectural insight. Storage and compute are completely independent, so you can scale each one separately and only pay for what you actually use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-cluster warehouses.&lt;/strong&gt; 100 analysts running queries at the same time? Each gets their own compute cluster. No one slows anyone else down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best-in-class data sharing.&lt;/strong&gt; You can share live data with partners or other teams without copying it. This is genuinely impressive and something the other two struggle to match.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Travel.&lt;/strong&gt; Accidentally deleted a table? You can recover it — up to 90 days back depending on your plan. This has saved countless data teams from disaster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zero-Copy Cloning.&lt;/strong&gt; Clone an entire database instantly with no extra storage cost. Perfect for test environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pricing:&lt;/strong&gt; Credit-based, per second of compute. Easy to control once you understand it, but can surprise you if you leave warehouses running.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Teams that work across multiple clouds, organisations that need to share data externally, and companies that want maximum flexibility.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔴 Redshift
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The AWS native. Powerful if you’re already there.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Amazon Redshift is AWS’s data warehouse, and if your company is already deep in the AWS ecosystem, it’s a natural fit. The integration with S3, Lambda, Glue, Kinesis, and the rest of the AWS stack is seamless in a way that Snowflake and BigQuery simply can’t replicate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What makes Redshift stand out:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deep AWS integration.&lt;/strong&gt; If you’re already using S3 for storage, IAM for access control, or Kinesis for streaming — Redshift plugs in with minimal friction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redshift Serverless.&lt;/strong&gt; The newer serverless option means you don’t have to manage clusters anymore. It scales automatically and you pay only for what you use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strong performance for large structured datasets.&lt;/strong&gt; Redshift uses columnar storage and is highly optimised for analytical queries across large volumes of structured data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enterprise security.&lt;/strong&gt; Deep IAM integration, VPC support, encryption at rest and in transit. If your company has strict security requirements, Redshift ticks all the boxes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pricing:&lt;/strong&gt; Traditionally priced per hour for provisioned clusters, which can get expensive at scale. Redshift Serverless is more flexible but costs can still add up. Reserved instances help significantly if you have predictable workloads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Companies already deeply invested in AWS who want tight integration with the rest of their AWS infrastructure.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔵 BigQuery
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Google’s beast. Serverless and stupidly fast.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;BigQuery is Google Cloud’s data warehouse, and it’s genuinely impressive. It’s the most truly serverless of the three — there’s no infrastructure to think about whatsoever. You just query data and Google handles everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What makes BigQuery stand out:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Truly serverless.&lt;/strong&gt; No clusters, no warehouses, no infrastructure decisions. Just write SQL and run it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generous free tier.&lt;/strong&gt; 10GB of storage and 1TB of query processing free every month. This makes it the best option for learning or for small projects where you don’t want to spend anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BigQuery ML.&lt;/strong&gt; You can train and run machine learning models using SQL — no Python required. This is genuinely unique and incredibly powerful for teams that want ML without a dedicated data science team.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Looker Studio integration.&lt;/strong&gt; Connects directly to Google’s BI and visualisation tools with zero setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pricing:&lt;/strong&gt; Pay per query based on data scanned. This sounds great until someone writes a poorly optimised query on a huge table and gets a surprise bill. Always use &lt;code&gt;LIMIT&lt;/code&gt; and partition your tables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; GCP-native teams, data science and ML workloads, anyone who wants to start for free, and teams already using Google Workspace or Looker.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cheat Sheet
&lt;/h2&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;❄️ Snowflake&lt;/th&gt;
&lt;th&gt;🔴 Redshift&lt;/th&gt;
&lt;th&gt;🔵 BigQuery&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cloud&lt;/td&gt;
&lt;td&gt;Any (AWS/Azure/GCP)&lt;/td&gt;
&lt;td&gt;AWS only&lt;/td&gt;
&lt;td&gt;GCP only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pricing&lt;/td&gt;
&lt;td&gt;Per second&lt;/td&gt;
&lt;td&gt;Per hour&lt;/td&gt;
&lt;td&gt;Per query&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free tier&lt;/td&gt;
&lt;td&gt;30-day trial&lt;/td&gt;
&lt;td&gt;2 months&lt;/td&gt;
&lt;td&gt;Always free (1TB/mo)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Setup&lt;/td&gt;
&lt;td&gt;Easy&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Very easy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ML built-in&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data sharing&lt;/td&gt;
&lt;td&gt;Best in class&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Which One Should You Pick?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pick Snowflake if&lt;/strong&gt; you work across multiple clouds, your team needs to share data externally, or you want maximum long-term flexibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pick Redshift if&lt;/strong&gt; your company is already all-in on AWS and you need tight integration with the rest of the AWS ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pick BigQuery if&lt;/strong&gt; you’re on GCP, you want built-in ML capabilities, or you want to start completely free.&lt;/p&gt;




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

&lt;p&gt;If you’re just starting out and want to learn, &lt;strong&gt;BigQuery&lt;/strong&gt; is the easiest entry point — free tier, no setup, and you can have your first query running in minutes.&lt;/p&gt;

&lt;p&gt;If you’re job hunting in data engineering, &lt;strong&gt;Snowflake&lt;/strong&gt; is the one showing up most in job listings right now. It’s worth learning regardless of which one your company uses.&lt;/p&gt;

&lt;p&gt;If you’re at an AWS-heavy company, &lt;strong&gt;Redshift&lt;/strong&gt; is likely already in your stack — and getting good at it will make you immediately useful to your team.&lt;/p&gt;




&lt;p&gt;Which one does your company use? Drop a comment below 👇&lt;/p&gt;

&lt;p&gt;Follow me on Instagram at &lt;a href="https://www.instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://www.instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python and Snowflake tips every week 💙&lt;/p&gt;

</description>
      <category>sql</category>
      <category>beginners</category>
      <category>snowflake</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>What is Snowflake? A Beginner's Guide to the Cloud Data Warehouse Everyone's Talking About</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Wed, 11 Mar 2026 15:31:16 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/what-is-snowflake-a-beginners-guide-to-the-cloud-data-warehouse-everyones-talking-about-42j3</link>
      <guid>https://dev.to/neha_christina_1ac8651819/what-is-snowflake-a-beginners-guide-to-the-cloud-data-warehouse-everyones-talking-about-42j3</guid>
      <description>&lt;p&gt;If you've seen "Snowflake" in job listings and had no idea what it meant — you're not alone.&lt;/p&gt;

&lt;p&gt;It shows up everywhere in data engineering, data analytics, and even business intelligence roles. But nobody ever explains what it actually &lt;em&gt;is&lt;/em&gt; in plain English.&lt;/p&gt;

&lt;p&gt;Until now.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Snowflake?
&lt;/h2&gt;

&lt;p&gt;Snowflake is a &lt;strong&gt;cloud-based data warehouse&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's the technical answer. Here's the human one:&lt;/p&gt;

&lt;p&gt;Think of a regular database like a filing cabinet in your office. It works fine when you have a few thousand files. But what happens when you have &lt;em&gt;billions&lt;/em&gt; of files, hundreds of people searching at the same time, and the cabinet needs to grow overnight?&lt;/p&gt;

&lt;p&gt;It breaks.&lt;/p&gt;

&lt;p&gt;Snowflake is the solution. It's a giant, intelligent filing warehouse that lives in the cloud — it can grow instantly, never slows down under pressure, and lets hundreds of people query it simultaneously without fighting over resources.&lt;/p&gt;




&lt;h2&gt;
  
  
  How is it Different from a Regular Database?
&lt;/h2&gt;

&lt;p&gt;Traditional databases like MySQL or PostgreSQL were designed for a different era. They work great for small-to-medium workloads, but they hit a wall when data gets big.&lt;/p&gt;

&lt;p&gt;Here's what happens with traditional databases at scale:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They get slow.&lt;/strong&gt; Query a table with billions of rows and you might be waiting minutes — or hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They're hard to scale.&lt;/strong&gt; Need more capacity? You have to physically buy and set up new servers. That takes time and money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They struggle with many users.&lt;/strong&gt; The more people running queries at once, the slower it gets for everyone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They're expensive to maintain.&lt;/strong&gt; You need a dedicated database administrator just to keep things running smoothly.&lt;/p&gt;

&lt;p&gt;Snowflake was built from the ground up to solve all four of these problems at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Snowflake Solves It
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Massively parallel processing.&lt;/strong&gt; When you run a query, Snowflake doesn't run it on one machine. It splits the work across thousands of servers simultaneously. A query that would take 10 minutes on a traditional database can take seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Auto-scaling.&lt;/strong&gt; Need more compute power? Snowflake spins up additional capacity in seconds — automatically. When you're done, it scales back down. You only pay for what you use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-cluster warehouses.&lt;/strong&gt; Snowflake can run multiple compute clusters at the same time. 100 analysts running queries simultaneously? Each gets their own resources. No one slows anyone else down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Separation of storage and compute.&lt;/strong&gt; This is the key architectural insight that makes everything else possible. In a traditional database, storage and compute are tightly coupled. In Snowflake, they're completely separate — which means you can scale each one independently.&lt;/p&gt;




&lt;h2&gt;
  
  
  5 Snowflake Terms You'll Hear Everywhere
&lt;/h2&gt;

&lt;p&gt;Once you start working with Snowflake, these five terms come up constantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Warehouse&lt;/strong&gt; — This is the compute engine. When you run a query, a virtual warehouse does the actual processing. You can have multiple virtual warehouses for different teams or workloads, and they don't interfere with each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database &amp;amp; Schema&lt;/strong&gt; — Just like in any SQL database, you organize your data into databases and schemas (think of them as folders and subfolders). Your tables live inside schemas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Travel&lt;/strong&gt; — If someone accidentally deletes a table or overwrites data, you can travel back in time and recover it — up to 90 days back on some plans. This has saved many data teams from disaster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zero-Copy Cloning&lt;/strong&gt; — You can clone an entire database, schema, or table instantly with no additional storage cost. Snowflake doesn't duplicate the actual data; it just creates a pointer to the same underlying data. Perfect for creating test environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Snowpipe&lt;/strong&gt; — Snowflake's continuous data ingestion service. Instead of loading data in batches, Snowpipe automatically loads new data into Snowflake as soon as it arrives in your cloud storage.&lt;/p&gt;




&lt;h2&gt;
  
  
  Should You Learn Snowflake?
&lt;/h2&gt;

&lt;p&gt;Short answer: yes.&lt;/p&gt;

&lt;p&gt;If you're working in data — or want to work in data — Snowflake is one of the most valuable skills you can add to your toolkit right now.&lt;/p&gt;

&lt;p&gt;Here's why:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's in thousands of job listings.&lt;/strong&gt; Search for data engineer, data analyst, or analytics engineer on any job board and Snowflake shows up constantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's growing fast.&lt;/strong&gt; Snowflake is now used by over 8,000 companies including Netflix, Adobe, Capital One, DoorDash, and Pfizer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your SQL already works.&lt;/strong&gt; If you know &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;WHERE&lt;/code&gt;, &lt;code&gt;JOIN&lt;/code&gt;, and &lt;code&gt;GROUP BY&lt;/code&gt; — you already know how to query Snowflake. The learning curve is much lower than people expect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It commands higher salaries.&lt;/strong&gt; Roles that list Snowflake as a requirement consistently pay more than equivalent roles that don't.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Get Started
&lt;/h2&gt;

&lt;p&gt;The best way to start is free:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to app.snowflake.com and sign up for a 30-day free trial — no credit card required&lt;/li&gt;
&lt;li&gt;Create a virtual warehouse (just click through the setup wizard)&lt;/li&gt;
&lt;li&gt;Load a sample dataset (Snowflake provides several built-in ones)&lt;/li&gt;
&lt;li&gt;Start querying with SQL you already know&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Within an hour you'll have run your first Snowflake query and the whole thing will feel far less intimidating.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;In a future post I'll cover how Snowflake compares to other cloud data warehouses like BigQuery and Redshift — and when to use each one.&lt;/p&gt;

&lt;p&gt;For now: Snowflake is not as scary as it sounds, and if you already know SQL, you're more than halfway there.&lt;/p&gt;




&lt;p&gt;Which Snowflake feature surprised you most? Drop a comment below 👇&lt;/p&gt;

&lt;p&gt;Follow me on Instagram at &lt;a href="https://www.instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://www.instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python and Snowflake tips every week 💙&lt;/p&gt;

</description>
      <category>snowflake</category>
      <category>dataengineering</category>
      <category>sql</category>
      <category>beginners</category>
    </item>
    <item>
      <title>SQL Window Functions Don't Have to Be Scary 🪟</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Mon, 09 Mar 2026 11:01:18 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/sql-window-functions-dont-have-to-be-scary-146d</link>
      <guid>https://dev.to/neha_christina_1ac8651819/sql-window-functions-dont-have-to-be-scary-146d</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If you've ever seen &lt;code&gt;OVER (PARTITION BY ... ORDER BY ...)&lt;/code&gt; in a SQL query and quietly closed the tab — this post is for you.&lt;/p&gt;

&lt;p&gt;Window functions are one of those topics that look intimidating at first but become incredibly powerful once they click. And once you learn them, you'll wonder how you ever wrote SQL without them.&lt;/p&gt;

&lt;p&gt;By the end of this post you'll understand 5 essential window functions, when to use each one, and exactly how they differ from each other.&lt;/p&gt;

&lt;p&gt;Let's go.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Even Is a Window Function?
&lt;/h2&gt;

&lt;p&gt;A regular aggregate function like &lt;code&gt;SUM()&lt;/code&gt; or &lt;code&gt;COUNT()&lt;/code&gt; collapses your rows into a single result. Window functions do calculations &lt;strong&gt;across rows — without collapsing them.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Regular aggregate: collapses all rows into one&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;dept&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 sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Window function: keeps all rows, adds a calculated column&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;dept_total&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key difference: &lt;code&gt;GROUP BY&lt;/code&gt; gives you one row per group. Window functions give you &lt;strong&gt;all your rows back&lt;/strong&gt;, plus a new calculated column alongside them.&lt;/p&gt;

&lt;p&gt;The syntax always follows this pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;function_name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;column&lt;/span&gt;   &lt;span class="c1"&gt;-- optional: defines the group&lt;/span&gt;
  &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;column&lt;/span&gt;       &lt;span class="c1"&gt;-- optional: defines row order within the group&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Function #1: ROW_NUMBER()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Assigns a unique sequential number to each row within a partition. No ties — every row gets a different number.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;ROW_NUMBER&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;dept&lt;/span&gt;
    &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;row_num&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;dept&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;th&gt;row_num&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;Eng&lt;/td&gt;
&lt;td&gt;90k&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;Eng&lt;/td&gt;
&lt;td&gt;85k&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Carol&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;70k&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dave&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;65k&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Even if Alice and Bob had the same salary, they'd still get different row numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get the most recent record per user (filter where &lt;code&gt;row_num = 1&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Deduplicate data&lt;/li&gt;
&lt;li&gt;Paginate query results&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Function #2: RANK()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Like ROW_NUMBER, but ties get the SAME rank — and the next rank skips.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;RANK&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;score&lt;/th&gt;
&lt;th&gt;rank&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;95&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;95&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Carol&lt;/td&gt;
&lt;td&gt;88&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dave&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice rank 2 is missing. Alice and Bob both scored 95 so they share rank 1 — and the next rank jumps to 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ranking students by exam score&lt;/li&gt;
&lt;li&gt;Ranking products by sales volume&lt;/li&gt;
&lt;li&gt;Any scenario where ties are meaningful and gaps are acceptable&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Function #3: DENSE_RANK()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Like RANK, but NO gaps after ties.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;DENSE_RANK&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;dense_rank&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;score&lt;/th&gt;
&lt;th&gt;dense_rank&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;95&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;95&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Carol&lt;/td&gt;
&lt;td&gt;88&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dave&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Same data — but now Carol gets rank 2, not rank 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RANK vs DENSE_RANK — the simple rule:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;RANK()&lt;/code&gt; when gaps make sense (sports — if two people tie for gold, no one gets silver)&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;DENSE_RANK()&lt;/code&gt; when gaps look wrong (medal tables, internal employee levels)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Function #4: LAG()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Lets you look at the value from the PREVIOUS row.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="k"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;LAG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;revenue&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="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;prev_revenue&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;month&lt;/th&gt;
&lt;th&gt;revenue&lt;/th&gt;
&lt;th&gt;prev_revenue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Jan&lt;/td&gt;
&lt;td&gt;10k&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Feb&lt;/td&gt;
&lt;td&gt;12k&lt;/td&gt;
&lt;td&gt;10k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mar&lt;/td&gt;
&lt;td&gt;11k&lt;/td&gt;
&lt;td&gt;12k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apr&lt;/td&gt;
&lt;td&gt;15k&lt;/td&gt;
&lt;td&gt;11k&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;January has &lt;code&gt;NULL&lt;/code&gt; for &lt;code&gt;prev_revenue&lt;/code&gt; because there's no row before it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Month-over-month or year-over-year comparisons&lt;/li&gt;
&lt;li&gt;Calculating the change between consecutive rows&lt;/li&gt;
&lt;li&gt;Detecting gaps or jumps in a time series&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Function #5: LEAD()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Like LAG — but looks at the NEXT row instead.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="k"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;LEAD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;revenue&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="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;next_revenue&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;month&lt;/th&gt;
&lt;th&gt;revenue&lt;/th&gt;
&lt;th&gt;next_revenue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Jan&lt;/td&gt;
&lt;td&gt;10k&lt;/td&gt;
&lt;td&gt;12k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Feb&lt;/td&gt;
&lt;td&gt;12k&lt;/td&gt;
&lt;td&gt;11k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mar&lt;/td&gt;
&lt;td&gt;11k&lt;/td&gt;
&lt;td&gt;15k&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apr&lt;/td&gt;
&lt;td&gt;15k&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;April has &lt;code&gt;NULL&lt;/code&gt; because there's no row after it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cheat Sheet
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Ties&lt;/th&gt;
&lt;th&gt;Gaps&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ROW_NUMBER()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Different numbers&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;Deduplication, pagination, latest record per group&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;RANK()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same rank&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Sports rankings, exams&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DENSE_RANK()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same rank&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Leaderboards, levels, medal tables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LAG()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;Compare to previous row&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LEAD()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;Compare to next row&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  One Thing to Remember
&lt;/h2&gt;

&lt;p&gt;All window functions follow the same structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;   &lt;span class="c1"&gt;-- your "group by" (optional)&lt;/span&gt;
  &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;       &lt;span class="c1"&gt;-- row order within the group (optional)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;PARTITION BY&lt;/code&gt; is like &lt;code&gt;GROUP BY&lt;/code&gt; — but it doesn't collapse your rows. &lt;code&gt;ORDER BY&lt;/code&gt; inside &lt;code&gt;OVER()&lt;/code&gt; controls how rows are ordered &lt;strong&gt;within each window&lt;/strong&gt;, independently of the query's own &lt;code&gt;ORDER BY&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Once you're comfortable with these 5, explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SUM()&lt;/code&gt;, &lt;code&gt;AVG()&lt;/code&gt;, &lt;code&gt;COUNT()&lt;/code&gt; as window functions&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NTILE()&lt;/code&gt; for splitting rows into buckets&lt;/li&gt;
&lt;li&gt;Frame clauses like &lt;code&gt;ROWS BETWEEN&lt;/code&gt; for rolling calculations&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Which window function confused you the most before reading this? Drop a comment below 👇&lt;/p&gt;

&lt;p&gt;Follow me on Instagram at &lt;a href="https://www.instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://www.instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python and Snowflake tips every week 💙&lt;/p&gt;

</description>
      <category>sql</category>
      <category>dataengineering</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>🐍 5 Python Mistakes Every Junior Dev Makes (And How to Fix Them)</title>
      <dc:creator>Neha Christina</dc:creator>
      <pubDate>Fri, 06 Mar 2026 08:19:16 +0000</pubDate>
      <link>https://dev.to/neha_christina_1ac8651819/5-python-mistakes-every-junior-dev-makes-and-how-to-fix-them-o3b</link>
      <guid>https://dev.to/neha_christina_1ac8651819/5-python-mistakes-every-junior-dev-makes-and-how-to-fix-them-o3b</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If you're a junior developer writing Python, chances are you've made at least one of these mistakes — and you didn't even know it. These aren't syntax errors that your IDE catches. They're subtle bugs and bad habits that slip through code reviews and slow down your growth.&lt;br&gt;
Let's fix all five.&lt;/p&gt;
&lt;h2&gt;
  
  
  Mistake #1: Mutable Default Arguments
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&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;add_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt;
    &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&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;lst&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks harmless, but Python creates the default list once at function definition — not on every call. So every call shares the same list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&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;add_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&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;lst&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&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;lst&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Always use None as your default for mutable arguments, then create the object inside the function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #2: Skipping List Comprehensions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&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;squares&lt;/span&gt; &lt;span class="o"&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;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&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="n"&gt;squares&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&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;squares&lt;/span&gt; &lt;span class="o"&gt;=&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="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cleaner, faster, and more Pythonic. Senior devs will notice immediately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #3: Bare Exception Catching
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&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;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A bare except catches everything — including KeyboardInterrupt and SystemExit. This makes bugs invisible and debugging a nightmare.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&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;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ZeroDivisionError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Error: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Always catch specific exceptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #4: String Concatenation in Loops
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each += creates a brand new string object in memory. In a loop, that's O(n²).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.join() is O(n) and the idiomatic Python way to build strings from iterables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake #5: Not Using enumerate()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruits&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruit&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;enumerate() exists exactly for this. Use it — it's cleaner and avoids off-by-one errors.&lt;/p&gt;

&lt;p&gt;Which one were you guilty of? Drop a comment below 👇&lt;br&gt;
Follow me on Instagram &lt;a href="https://instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://instagram.com/techqueen.codes&lt;/a&gt; for visual SQL, Python &amp;amp; Snowflake tips every week.&lt;/p&gt;

&lt;p&gt;Enjoyed this? Save the visual cheat sheet on Instagram → &lt;a href="https://instagram.com/techqueen.codes" rel="noopener noreferrer"&gt;https://instagram.com/techqueen.codes&lt;/a&gt;&lt;/p&gt;

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