• yield does not work?

Question related to mission Duplicate Zeros


The <Best Clear Solution> offered to me is "yield" by Phil15 (Sep 13, 2022):

def duplicate_zeros(donuts):
    for o in donuts:
        yield o
        if not o:
            yield o

I really like the way, how a generator avoids building a local copy of the new list. It would be great to learn more about this topic. But when I copy-paste the code and hit RUN, all I get is:

<generator object duplicate_zeros at 0x7fbac8c74350>
 <module>, 16

It seems that wrapping the function in a list(..) would make the example work:

print(list(duplicate_zeros([1, 0, 2, 3, 0, 4, 5, 0])))

But how did the solution passed the tests?