Python Forum

Full Version: Hello world! program, window disappears
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.

I am a beginner in Python coding.

I wrote hello world program.

print('Hello, world!')
But when I run it on Windows 10, the window appears and disappears. What can I do to make it stay until I press a key?

I found this: https://stackoverflow.com/questions/9833...ressed-key

but it didn't really help.. Thank you.
How do you run the program? Try to put this line:
_ = input()
And when you run the program hit Enter when it stops.
just
input()
will suffice

or run your script from command prompt, not by double-click on it
The question has been answered but I would like to add my two cents. While you are learning python you might benefit from simply running your python scripts directly from the terminal. Because when you start learning, you're not creating gui programms but rather your making command line programs. You do so by typing python or python3 followed by the name of your python script file. You may also benefit by knowing that from the terminal you can type python3 on its own and access a interactive python interpreter. The advantage to doing this is that you can learn a lot more by doing things yourself. Typing things like 4+5, you will be surprised what you can learn.