Avoid dupplicates with the yield keword?
Avoid duplicates with the yield keword? Question: Is it possible to avoid duplicates in a yield generator? For example def foo(): for i in (1,1,1,2,3,4,5): #check if "i" have not been "yielded" yet? yield i gen = foo() numbers = list(gen) print(numbers) >>>[1,2,3,4,5] numbers = list(gen) is cheating, the goal is to do it within …