def test(): print('enter') yield 1 print('next') yield 2 print('next next') yield 3 for i in test(): print(i)
output
enter 1 next 2 next next 3
This shows the role of yield, and you will know it when you debug it.
def test(): print('enter') yield 1 print('next') yield 2 print('next next') yield 3 for i in test(): print(i)
output
enter 1 next 2 next next 3
This shows the role of yield, and you will know it when you debug it.