What is the output of the following code? from contextlib import contextmanager @contextmanager def tag(name): print("<%s>" % name) yield print("</%s>" % name) with tag('h1') : print('Hello')

Questions & AnswersCategory: Programming LanguageWhat is the output of the following code? from contextlib import contextmanager @contextmanager def tag(name): print("<%s>" % name) yield print("</%s>" % name) with tag('h1') : print('Hello')
Adam asked 2 years ago

What is the output of the following code?

from contextlib import contextmanager

@contextmanager

def tag(name):

    print("<%s>" % name)

    yield

    print("</%s>" % name)

with tag('h1') :

    print('Hello')

 
a. <%h1>
Hello
</%h1>
b. Hello
c. <h1>
</h1>
Hello
d. <h1>
Hello
</h1>