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?
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers