0

To start off I'm new to coding. To practice basic strings and commands I'm making a little decision-based game, you know the classic left or right type thing. The problem is that I do not know an exit command. I have it written to where if you make certain choices you die and when you die i want to have it written to where the script boots you. sort of like

print('You have died..exit?')

user_choice = input('Okay')

if user_choice == 'Okay':

(here is where i would put the exit code)

else:

(Exit code again...no getting out of it)

Please help! I litterally just started coding today...>.<

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
Liirum
  • 1
  • 2

1 Answers1

0

well to just close a program you can

import sys

and then wherever you want:

sys.exit(0)

Is there a method that tells my program to quit?

Community
  • 1
  • 1
nonsensei
  • 480
  • 4
  • 15