Python Programming - Exception Handling - Discussion
Discussion Forum : Exception Handling - General Questions (Q.No. 33)
33.
Consider the following Python code:
try:
x = int("abc")
except ValueError as e:
x = "Error: " + str(e)
What will be the value of "x" after the execution of this code?
Answer: Option
Explanation:
The
try block attempts to convert the string "abc" to an integer, causing a ValueError. The except block captures the exception and assigns an error message to "x."
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