My problem is that, first is when i copy and past to idle for example this:
print(“text”)
input(“\n\nclick Enter.”)
this shows me error:
SyntaxError: multiple statements found while compiling a single statement
When i save this in “test.py” file, i click file and window dissapear.
Another strange thing is that, i have old .py files in folder that i did before and its working, but when i copy this file to other folder its not working anymore.
I dont know how to solve this problems, before was seems all working fine, and now not.
For the IDLE part: print and input are 2 separate statements. Enter one statement at a time in Shell. Either paste and delete 1 before Enter or paste into an IDLE editor and run.
@barry-scott Input statements at the end of a file are a way to prevent the window from disappearing until one hits the enter/return key. Unclear to me what the problem is.
it seems to be something wrong with my pc.
When i will do same thing on other pc its working.
I do simple program i click on it, window comes out and its all like should be.
On my PC, when i do same program in idle, i save it and i click on it, its behave like without “input(“\n\nclick Enter.”)” commend its closing imidiatly.
Old programs that i had saved in some folder, are working good, but when i will copy them to other folder, they stop working.
One idea that i have its maybe some other program prevent me to open this new files on my pc.
Antivirus maybe. I will do format anyway.
If you have the py launcher installed and associated with “.py” files, a simple workaround for testing is to use a shebang that exits into interactive mode, e.g. “#!/usr/bin/python3 -i”. This works even if the script exits due to an unhandled exception.
I don’t use this shebang technique much anymore, at least not in Windows 11. I have Terminal set as my default terminal. It can be configured to keep the tab of a console session open after the session has ended. Or it can be configured to keep the tab open only when the process that allocated the console (e.g. “py.exe”) exits with a non-zero status code.