Examveda

What will be the output of the following Python code?
def foo():
    try:
        return 1
    finally:
        return 2
k = foo()
print(k)

A. 1

B. 2

C. 3

D. error, there is more than one return statement in a single try-finally block

Answer: Option B


This Question Belongs to Python Program >> Exception Handling In Python

Join The Discussion

Related Questions on Exception Handling in Python