I am trying to do a text adventure game with multiple adventures. When I try to end an adventure, it just starts another one. How do I make the program to stop running when one adventure ends?
Welcome to the community, @Salmaan-B!
The number of solutions depend on how you built your code, but if you want to end your program instantly, which is not the best practice IMO, you can just use
Also, like I said, this works but isn’t the best practice. You should end your code naturally if possible. Can you provide a link to your Repl or paste your code in a reply?
Yeah, it seems to me that it would be a lot of work to refactor your code to let it end naturally, so I would just use
exit() in this scenario.
Or you know, you can just use
That works with scripts? Thought that was a shell-only thing. Well, you learn something new every day. I’ll edit my replies now.
exit() it’s a text adventure game, as long as you aren’t opening files and then not closing them or something it isn’t going to cause issues.
exit(status), you can use