Ask coding questions

← Back to all posts
how to end code
NathanJoseph4 (0)

bit of a basic question, apologies in advance

I'm working on a text based adventure game in python and I've created a function "death()" that is called upon whenever the user makes a choice that leads them to death. The code is as follows:

def death():
print("death message")

quit() returns the phrase "repl process died unexpectedly." Is there any way to end the code completely without this popping up?

19ecal (230)

No there is not a way to exit without this message

OldWizard209 (1101)

You can import sys at the top like :

import sys

And then exit in the death() function:

def death():
    print("You ded :|")
NathanJoseph4 (0)

This is still giving me that same error message. When using other IDEs the code just stops like I want it to so I'm thinking it's something specific to