Command to finish the program

Asked

Viewed 25,847 times

-2

Is there a command to finish the program in Python or can only finish using ways like this:

print()
  • 2

    I don’t understand. print does not end the program. What exactly are you trying to do?

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.

  • The function print() serves only to skip a line.

1 answer

5

Generally the end of the code ends the execution, of course if it is in a function called only the function will be finished and will return to who called.

It is recommended to leave the intention explicit unless in too trivial codes, so putting a final Return would be a good idea.

If you want to stop immediately at any point you can use sys.exit(). Don’t forget to import the module import sys.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.