Python Programming - Exception Handling - Discussion

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

Post your comments here:

Your comments will be displayed after verification.