def tentimes(): i = 0 while True: if i == 10: raise StopIteration yield i i = i + 1 for i in tentimes(): print(i) 0 1 2 3 4 5 6 7 8 9 --------------------------------------------------------------------------- StopIteration Traceback (most recent call last) <ipython-input-1-20f0585f0e57> in tentimes() 4 if i == 10: ----> 5 raise StopIteration 6 yield i StopIteration: The above exception was the di