I am very new, and am attempting to learn the Python language so please forgive my ignorance.Here is the problem, whenever I run a Python script from the cmd prompt as soon as it runs it (cmd prompt screen) dissappears immediately after running. How do you keep the cmd screen open with whatever the last print command has on screen ?
I think if you right-click on the file and go to its properties you may have an option. There are two better ways to do it. One is to run it from an already-open command prompt; e.g., hit Windows-R to bring up the run dialog, type `cmd' and enter to bring up a command prompt, then type `cd C:\<whatever>' where <whatever> is the folder where your file is, and then run `python myfile.py'. The second way is to make it so that your script itself waits for you to hit enter before it quits. I believe the way to do that in Python is to put a single `raw_input' statement at the end of the file. That will wait for you to hit enter before the script ends, and therefore before the command prompt closes.
raw_input() will work fine for that.
Thanks for the help i'll give it a try.
the raw_input() works Thank you
Awesome! :)
@rcvegas40 I've been learning Python for a couple of years, I'm not brilliant at it, but I've got it down. If you have any problems at all, just post a question in the Computer Science Group or the MIT 6.0 Group and I'd be happy to help. There's a couple of other guys on here too. They'd be happy to help if you need anything. Welcome to the site by the way :)
Join our real-time social learning platform and learn together with your friends!