Completely agreed, @IraWatt! For a temporary workaround, I've learned to be very careful with the Python tool. It most often wipes the code when I have two Python tools in my Designer instance at any time. Especially in separate workflows, although sometimes it still happens within the same workflow. I close a workflow with a Python tool before clicking on any other Python tool.
Thanks @clmc9601! I didn't know about the close workflow workaround; I'll definitely use that for more complex code as up till this point I have just been copying everything into notepad 😅.