Python Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 14)
14.
Consider the following Python code:
try:
    value = int("abc")
except ValueError:
    result = "Invalid conversion"
finally:
    result += " - Finally block executed"
What will be the value of "result" after the execution of this code?
"Invalid conversion"
"Invalid conversion - Finally block executed"
" - Finally block executed"
Raises an exception
Answer: Option
Explanation:
The finally block is executed regardless of whether an exception occurs or not. It appends " - Finally block executed" to the "result" string.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.