fbpx

How would you handle multiple exceptions in Python? Can you give an example?

To handle multiple exceptions, you can use a tuple in the except clause. Here's an example:

try:
    # some code that may raise exceptions
except (TypeError, ValueError) as e:
    print(f"Caught an exception: {e}")

 

# Dream job to realty