def gen(): try: yield 1 yield 2 except: print('hi') def func(): for x in gen(): return x print(func()) This code prints hi and then prints 1. Why doesn't it just print 1? What exception was raised? Continue reading...