def generator(): i=0 while True: i +=2 yield i for item in generator(): print(item) if item>20: break