Ask coding questions

← Back to all posts
Python spacing and tab issue
stevemiller (34)

Sometimes, when I enter python code directly into, i run into Python errors where the indent or spacing is reported as uneven even if I've used the tab key.

I have a workaround. I copy and the paste a previous lines tabs. It's annoying to have to do this. I work in Python 3. Is this an issue with the editor wrt to spaces/tabs?


what's the problem is?

ArshdeepSingh10 (2)

@HARDIKTIWARI I am facing the same problem.

adipool02 (1)

@HARDIKTIWARI I am also facing the same problem.

PriyankaMehta2 (1)

@HARDIKTIWARI i am facing the same problem ..... have you found how to complete the task....

ChristopherPasa (5)

I found in the settings when changing the indent type from spaces to tabs, the problem seemed to be fixed for me.

turroscott (7)

The quickest fix is to use command F and highlight one of the tabs that you entered. Now replace these faulty tabs with one that was used in the previous lines.

RobertoBean (41)

You don't need to copy and paste the tabs from previous lines. When you place a colon, then use the down arrow key to start typing on the next line, will automatically indent the correct amount of space for you. Also, if it's already indented out to a certain place, using the down arrow key again will keep it indented at the same level.

Vivekanand12 (2)

return price_a/price_b
indentation error in this line

ak11398 (4)

Still not able to fix this problem someone please help...........

LaykenGombeda (4)

go to settings and find indent type and change it or make sure it is set as tabs, then hit CTRL + F and hit SPACE and find the line that is bugging out your code and delete it and rewrite it with tabs, should work if not then ive got no clue

totoeevee (14)

sooooo yeah had this problem too
figured out how to fix it
so change indent type to tabs
highlight ALL your code
so after u highlight all ur code, indent and then dedent with CMD/ctrl ] and then CMD/ctrl[.
it will auto format for you and yay

Jorgmassih (1)

@totoeevee thanks! It worked for me

totoeevee (14)

@v2couto use control then
Ctrl ] then Ctrl [
if anyone is on mac use CMD ] then CMD [