formattingpython-idle

Why is code copied from IDLE always rejected?


I am unable to persuade this system to accept my question because it tells me that I should indent my code by 4 spaces. As far as I can tell it is all properly indented, as it runs properly within IDLE. Can anyone tell me what it is that triggers this reaction?

I have tried applying Ctrl-K and Ctrl-M to blocks of code, or my descriptions, and tried adding 4 spaces where there are none, but none of these will remove the block to posting. The Help file tells me that "You can also select text and press CTRL+K to toggle indenting as code." but it doesn't affect the indenting.


Solution

  • Three backticks on their own lines at the beginning and end:

    ```
    A code block with
    some code
    ```
    

    or, with four spaces:

        A code block with
        some code
    

    Both will look like:

    A code block with
    some code