Home » Programming Language (coding) » Python MCQ » What is the output of the following code? def foo(): try: print(1) finally: print(2) foo()

What is the output of the following code? def foo(): try: print(1) finally: print(2) foo()

What is the output of the following code?

def foo():
    try:
        print(1)
    finally:
        print(2)
foo() 

A. 1 2
B. 1
C. 2
D. none of the mentioned

Correct Answer: Option A. 12 

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
11 × 20 =