Search code examples
pythongoogle-colaboratoryindentationpep8

Change indentation level in Google Colab


I am using Google Colab to write Python code in their notebooks. Whenever I hit enter after a loop or conditional, the new line is automatically indented, which is good, but it uses only 2 whitespaces by default. This is contrary to the PEP-8 standard which recommends 4 whitespaces.

Why is this the case and how can I change this setting within Colab?


Solution

  • You can change it to 4 whitespaces through settings:

    Tools > Settings > Editor > Indentation width in spaces > Select 4