Python Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 16)
16.
Consider the following Python code:
try:
    x = int("42")
except ValueError:
    x = "Invalid conversion"
else:
    x += 1
finally:
    x *= 2
What will be the value of "x" after the execution of this code?
42
"42"
"Invalid conversion"
86
Answer: Option
Explanation:
The try block successfully converts the string "42" to an integer. The else block increments the value of "x" by 1, and the finally block multiplies "x" by 2.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.