Common Mistakes Junior Pythonistas make
Tags: python
Published: 2019-11-12 11:40:10

---
title: Common Mistakes Junior Pythonistas make
tags: python
cover_image: https://cdn.pixabay.com/photo/2019/11/08/11/56/cat-4611189_960_720.jpg
published: true
---
What Are The Most Common Mistakes Junior <a href="https://python.org">Python</a> Developers Should Avoid?

We all make mistakes, but sometimes these mistakes can be easily avoided if you've been given some worthwhile advice by someone whos been there before. Luckily, when it comes to Python, plenty of people have taken note of the issues they had while learning the language. 

<img src="https://media2.giphy.com/media/zOvBKUUEERdNm/giphy.gif?cid=790b76118f36942d26a83d51ee50f4ad6aa4f3f0ec8cfec9&rid=giphy.gif">

As with all coding languages, its normal to make mistakes here and there. There are a few mistakes, however, that would be easy to avoid if you know what to look for! We've compiled a list of things to watch out for while you're <a href="https://pythonbasics.org">learning Python</a>. 

## Incorrect Indentation 

Whereas most languages use indentation to improve their readability but dont depend on the practice, Python has woven indentation right into the fabric of their language. This means you cant afford to make any errors when it comes to formatting your code. 

For Python, the rule is to have 4 spaces for indention. Don't mix with 2,3,5 or a different amount of spaces as Python will simply not run your program.

Youll need to learn how to use Python to separate your blocks of code so everything flows nicely. Its important to make sure you get it right the first time. Not indenting properly can lead to a bug in your code if youre not careful. <a href="https://pythonspot.com/python-debugging/">Debugging</a> is tiresome enough on its own, but looking for a missing space or extra space will drive you crazy! 

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.stack.imgur.com%2F6wcuw.gif&f=1&nofb=1">

Avoid this mistake by practicing the fundamentals of indenting before you get too far into other aspects of Python. This will decrease your likelihood of making an error later on. 

## Error Handling

Speaking of errors, if you're new to programming error handling itself may prove to be a little tricky when you're starting out. All errors will seem a bit cryptic starting out - make sure you understand the basics of every error handling message you encounter by looking for information from other coders on <a href="https://stackoverflow.com">StackOverflow</a> or <a href="https://github.com">GitHub</a>. This will help you avoid making the same mistake as you continue to learn. 

Errors in Python are handled using a traceback. You'll get most of your errors from making a mistake in your syntax. This means you've likely forgotten a colon, parentheses, or have indentation issues. 

<img src="https://media3.giphy.com/media/xT9IgIc0lryrxvqVGM/giphy.gif?cid=790b761105aa54e42773038c2a2022635002ed2d25f66e7f&rid=giphy.gif">

Avoid spending too much time on this mistake by going through your code line by line and reading it out loud. Make sure you work through the purpose of each line of code in your head as you do this. Paying attention to the small details will help you pick up on your syntax errors quickly so you can move on to more important issues. 

## The LEGB Rule

Figuring out scope can be a bit of a pain for a newcomer in any language, but it's especially true in Python. Whereas other languages usually just have two <a href="https://pythonbasics.org/scope/">scopes</a> to work with (local and global variable scope) Python requires you to work with four scopes. These are commonly referred to as the LEGB Rule. 

The LEGB Rule refers to the way the variables are defined - Local, Enclosing, Global, and Built-in. You'll need to be careful about your decisions to assign variables. Once you make a decision about where to put your variables Python will consider them to be local to that particular scope - which may create problems later on if you're not intentional with your assignments. 

**Related links**
* <a href="https://pythonbasics.org">Learn Python programming</a>
* <a href="https://pythonspot.com/python-debugging/">Debug with Python</a>
* <a href="https://python.org">Download Python</a>