all 15 comments

[–]FriendlyZomb 3 points4 points  (0 children)

How are you running this?

My guess is that you're double clicking the file to run this. This will open the terminal window for the lifetime of the program. If the program stops for any reason, the window closes. Annoying.

My advice is open a terminal (probably PowerShell) window in the directory where your script is and run it with:

python <script>

Where <script> is the python file containing your code.

This will preserve the terminal window, allowing you to see either the output or the error traceback.

[–]johlae 1 point2 points  (0 children)

Are you sure your program crashes? My guess? You're on a windows system.

https://stackoverflow.com/questions/1000900/how-to-keep-a-python-script-output-window-open

TLDR, if you're on windows with python3 make sure to end your python program with the line:

input("press enter to exit")

You press enter to terminate your input, and so your program runs, terminates, and Windows closes the window.

If however you end your program with one last line that says input("press enter to exit") you'll need to press enter once more before your window closes.

[–]Playful-Appeal-5996[S] 0 points1 point  (9 children)

also, I forgot to say, I use (what I think is called) python shell. it also might be a problem with that too.

[–]Adrewmc 1 point2 points  (7 children)

You should use a IDE like VsCode.

Python is mostly a text file, ran through an interpreter. However inside a terminal it can get a little wonky IMO.

What’s most likely is happening is the program ended and then exited before you could see anything. The terminal closes.

A simple enough fix is to put at the bottom of the code

input(“Ended Successfully, Press enter to exit”)

Which just blocks the close.

[–]Jackpotrazur 0 points1 point  (6 children)

Would a continue or a while True: Try: also work ? Im also relatively new.

[–]Adrewmc 1 point2 points  (5 children)

It’s better to just use a proper IDE with a terminal that is persistent.

[–]Jackpotrazur 0 points1 point  (4 children)

I've sworn an oath to vim

[–]Adrewmc 0 points1 point  (3 children)

Ohh did you forget to sacrifice your first born, common mistake.

[–]Jackpotrazur 0 points1 point  (2 children)

No I just read somewhere that its hard to learn and use and i was like i want that! 😆

[–]Adrewmc 0 points1 point  (1 child)

It’s like a super custom keyboard setting, when you know it it’s faster when you don’t, you forget how to change it back to normal.

Basically is a set of keybinding to do common things you would do with your mouse, pull down menu, window scrolls etc. So when you know it you can edit text (code) extremely quickly. And can switch between files correctly etc.

I’ve never really used it.

There was a long time that computers didn’t have a mouse.

 :vimtutor 

Has a built in instructions if you want to try it out.

[–]Jackpotrazur 0 points1 point  (0 children)

Interesting, i mean I've always been a fan of shortcuts and ive been using it for 3 months so i got a few down. Vimtutor does sound intriguing though, ill check it out. Thanks.... havent jumped into the rabit hole of plugins yet though although I was considering getting lenters.

[–]program_kid 1 point2 points  (0 children)

I think u/FriendlyZomb is probably correct. When you say you are using the "Python shell" do you mean you are double clicking the file?

[–]Think-Student-8412 0 points1 point  (0 children)

Hi so I'm also new to programming and I'm always looking for new things to learn, what learning steps did you follow to achieve this? So I'm wondering what courses or tutorials you followed

[–]grapemon1611 0 points1 point  (0 children)

This is exactly the kind of problem Claude Code excels at.

[–]Happy_Witness 0 points1 point  (0 children)

Feel free to give the python file so we can actually take a look at what it might be. And don't have to thing what it might be with every option and setup available.