0

In Matlab, we can use function

error('please try again') 

to give a error message and exit the program.

Is there a similar function in Python? Thanks.

1
  • 1
    Exception handling would work. Commented Dec 4, 2014 at 5:12

2 Answers 2

2
raise Exception('please try again')

Using more informational Exception class is preferred.

Sign up to request clarification or add additional context in comments.

Comments

1

Rise an exception, e.g.:

raise Exception("please try again")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.