English

The finally block in Python is executed only if no exception occurs in the try block. - Computer Science (Python)

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?
2024-2025 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×