DEV Community

Cover image for Fixing Python Indentation
t4christ
t4christ

Posted on • Originally published at ucarecdn.com

Fixing Python Indentation

Atimes or most times some of us face the problem of indentation when it comes to writing code in python. The weird thing is that despite the fact that you think you gave the right indentation in your code editor, popularly visual studio code, you still get stucked in an indentation error. This can be so frustrating because I can tell you confidently that I have experienced this so many times. Good news! I have a solution to any indentation problem you might face when coding with python, this solution works all the time, again I mean all the time. I have experimented this and I can confidently say it works all the time.

The first thing you should do is select all the code block and press shift + tab to align all the code block to the left then hit the tab button the number of times you want to indent to the right. That is it, your indentation problem just got solved. For multiple blocks of code repeat the step above by pressing shift + tab to align the blocks of the code to left and hit tab the number of times you want to indent to the right and that solves the indentation issue.

Top comments (1)

Collapse
 
loki profile image
Loki Le DEV

This works in many editors and languages also!