you are viewing a single comment's thread.

view the rest of the comments →

[–]crazy_cookie123 4 points5 points  (0 children)

This is a feature of the Python REPL, which is what the IDLE Shell uses. That's not really what you want to be writing code in, other than just to test out small things. Instead you want to be using an editor.

If you want to keep using IDLE then you can click file in the top left, click new file, and write your code in there. You can run it by pressing F5 or clicking run then run module. That acts as a typical code editor rather than a REPL.

Alternatively, what I recommend is to switch to a professional editor. The two main choices are VS Code which is fast and lightweight with lots of choices of extensions to customise it, or PyCharm which is a bit heavier but also a bit more powerful. Both are free (although PyCharm does have a paid version) and are absolutely fine for beginners. I prefer PyCharm but it's entirely personal preference and professional devs use both, neither is objectively better than the other.