Python Programming - Conditional Statements - Discussion

Discussion Forum : Conditional Statements - General Questions (Q.No. 32)
32.
Which of the following is the correct way to handle multiple exceptions in a try-except block?
try:
    # code block
except Exception1:
    # handle Exception1
except Exception2:
    # handle Exception2
try:
    # code block
except Exception1, Exception2:
    # handle exceptions
try:
    # code block
except (Exception1, Exception2):
    # handle exceptions
try:
    # code block
catch Exception1:
    # handle Exception1
catch Exception2:
    # handle Exception2
Answer: Option
Explanation:
The correct syntax is to use a tuple in the except clause to handle multiple exceptions.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.