What will be the output of the following Python program?

try:
    print("A")
finally:
    print("B")
                        

Options

  • A. Only A
  • B. Only B
  • C. A followed by B
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. A followed by B

Detailed Explanation

The finally block executes whether an exception occurs or not, subject to process termination or other exceptional conditions.