1

I am new to python and I have been wondering if you can do something like this in python.

try:
   something():
if it throws an exception then try this:
   something1():
if it throws an exception again:
   print(exception)
1
  • 1
    You can put a try block inside another try block, or in an except block. Commented Oct 10, 2017 at 9:53

1 Answer 1

1

Of course you can.

try:
    something()
except Exception as exp:
    try:
        something1()
    except Exception as exp2:
        print(exp, exp2)
        raise exp # in case you want to raise the original exception
Sign up to request clarification or add additional context in comments.

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.