Default indentation level in Codecademy Python editor

Two-spaced code will cause most IDE’s to complain. Why has CodeAcademy chosen this standard? Four spaces is nearly universal.

1 Like

That is not true. You can set up your chosen linter to complain about indentation with two spaces, but usually, a number of spaces used in the indentation is part of user preferences settings. I don’t know any IDE that would complain about two spaces as an indentation. Furthermore, I don’t know any IDE where you wouldn’t be able to set two spaces as a standard indentation.

It is true that PEP recommends four spaces for indentation, but this is only a recommendation. There are many companies (for example Google) where software engineers use two spaces for indentation in the Python code.

Why Codecademy decided to use two spaces? Probably because of the limited space. Editor in the exercise layout does not occupy the whole width, so to make the code more readable and to prevent too many lines from wrapping they decided to use two spaces, but again, this is a purely aesthetic decision.

I would like to emphasize one fact. Problem posted by @marionbalazard642507 wasn’t caused by the number of spaces used as indentation. It was caused by mixed tabs and spaces in the indentation. The only thing that Codecademy can do to prevent this kind of problems in the future is to enable whitespace rendering in the editor and I have sent a request to do so.

1 Like

factoradic, thanks for the response.

I agree, if you stay strictly within the CodeAcademy editor, the main problem is mixing tabs & spaces, but I still maintain that the default choice for the editor is an inconvenient one for those of us who sometimes use a different IDE or editor (at least, those of us who who are not Google engineers.)

No, the IDE’s don’t complain about any particular number of tabs or spaces as long as it is consistent, but if I cross over back and forth between PyCharm and CodeAcademy I get into trouble pretty quickly.

Of course I can reset my defaults, but why should I have to? Out of the box, IDLE, PyCharm, SublimeText, Atom and Thonny all default to four spaces. So do online editors such as and In fact (although my search has admittedly been pretty limited), I have thus far been unable to find any Python editor that defaults to two spaces.

I like CodeAcademy; this is hardly a deal-breaker, but I fail to see why I need to be the one to reset the defaults in my own coding environment.

1 Like

Hm, I never had problems with indentations. I use Vim, VS Code and PyCharm and I was always able to define preferences for given workspace (so, for example, I have a Codecademy directory where indentation level is set to 2 spaces, not globally) or to set up automatic reindentation on paste. But I understand that this might be inconvenient for you.

I decided to move this discussion to a new topic as this is not related to the problem discussed in Need help on a projet plss. And now this is a feature request, so maybe default indentation level will be changed :slight_smile:

1 Like