I am very new to python.. I used the code
x = input(" Hey what is your name " )
print(" Hey, " + x)
input(" press close to exit ")
On windows, it's the CMD console that closes, because the Python process exists at the end.
To prevent this, open the console first, then use the command line to run your script. Do this by right-clicking on the folder that contains the script, select
Open console here and typing in
python scriptname.py in the console.
The alternative is, as you've found out, to postpone the script ending by adding a
input() call at the end. This allows the user of the script to choose when the script ends and the console closes.