Python Forum
Hello world! program, window disappears
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello world! program, window disappears
#1
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.
Reply
#2
How do you run the program? Try to put this line:
_ = input()
And when you run the program hit Enter when it stops.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
just
input()
will suffice

or run your script from command prompt, not by double-click on it
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,745 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,168 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Hello World! rufenghk 0 960 Jun-02-2022, 09:48 PM
Last Post: rufenghk
  Very new to Python world daveseaman 0 1,470 Jun-25-2021, 07:17 PM
Last Post: daveseaman
  Help | Classes to use in real world soothsayerpg 9 4,134 Jul-08-2019, 07:30 PM
Last Post: nilamo
  running python hello world Avarage_Joe 8 5,269 Apr-13-2018, 04:20 PM
Last Post: Avarage_Joe
  'Hello, World!' Problem - Urgent OmarSinno 7 4,538 Sep-07-2017, 06:22 AM
Last Post: OmarSinno
  how to generate random 3d world (like minecraft) in python hsunteik 3 98,338 Jan-06-2017, 06:35 PM
Last Post: metulburr
  Hello World issues when using %% with ipython landlord1984 5 8,882 Dec-11-2016, 10:11 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020