Advertisements
Advertisements
Question
The finally block in Python is executed only if no exception occurs in the try block.
Options
True
False
MCQ
True or False
Solution
This statement is False.
Explanation:
In Python, the final block is always executed regardless of whether an error occurs in the try block. It guarantees that cleanup code (such as shutting files or releasing resources) is executed regardless of what happens.
shaalaa.com
Is there an error in this question or solution?