Python Programming - Exception Handling - Discussion
Discussion Forum : Exception Handling - General Questions (Q.No. 7)
7.
Consider the following Python code:
try:
num = int("abc")
except ValueError:
print("Invalid conversion")
else:
print("Conversion successful")
What will be the output of this code?
Answer: Option
Explanation:
The
try
block attempts to convert the string "abc" to an integer, resulting in a ValueError. The except
block is executed, printing "Invalid conversion."
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