What is the output of the following code? def nameFeeder(): while True: fname = yield print('First Name:', fname) lname = yield print('Last Name:', lname) n = nameFeeder() next(n) n.send('George') n.send('Williams') n.send('John')

Questions & AnswersCategory: Programming LanguageWhat is the output of the following code? def nameFeeder(): while True: fname = yield print('First Name:', fname) lname = yield print('Last Name:', lname) n = nameFeeder() next(n) n.send('George') n.send('Williams') n.send('John')
Adam asked 2 years ago

What is the output of the following code?

def nameFeeder():

    while True:

        fname = yield

        print('First Name:', fname)

        lname = yield

        print('Last Name:', lname)

n = nameFeeder()

next(n)

n.send('George')

n.send('Williams')

n.send('John')

 
a. First Name: George
Last Name: Williams
b. First Name: George
Last Name: Williams
First Name: John
c. First Name: George
d. Results in Error