Member-only story

10 Fundamental Mistakes to Avoid When Coding in Python

Bora Erbaşoğlu
4 min readOct 7, 2024

--

Having devoted a significant amount of time using Python, I have made and am still making several mistakes, not only mine but also the mistakes learned from others. Python is a great language and very easy to learn, but there are some peculiarities to it. In this section, I want to give some basic mistakes that you should avoid if you are looking to enhance your skills as a Python coder.

1. Confusing the indentation rules

One of the first challenges which the majority of the freshers encounter is the indentation in Python, which is very strict. In contrast to languages with braces which enclose code blocks, Python uses the levels of indentation. In case the code is not properly indented syntax errors might occur or worse, there might be logical errors which are very hard to detect. All the time be sure that the lines of code are all properly indented from the designed structure.

2. Mutable Default Arguments

Another important mistake is when using mutable objects such as a list or a dictionary as default arguments within a function. For instance:

This function can exhibit unusual characteristics in that the default list is only created one time. Every next one that follows shall now alter this exact same list…

--

--

Bora Erbaşoğlu
Bora Erbaşoğlu

Written by Bora Erbaşoğlu

Predictive Development Manager, AI Researcher, Python,React, React Native, PHP, Java Expert professionally since 1999. Open for consulting & dev projects

No responses yet