How do I know if a generator object generates output?
Look at this code: https://code.sololearn.com/clfz9prfS87c In line 40, I created a generator object (res). I know that I can use next() or a for each loop to iterate over the objects that the generator yields/returns (that's what I do in lines 42-45), but how can I tell whether or not the generator object actually returns something? I hope you get what I mean... Something like len(res) to see that the generator returns two objects (but that doesn't work). E.g., in the code linked above, the generator won't return anything for the range 0-1000. So if I try to iterate over the returned objects, nothing will happen. I use a boolean variable (f, lines 41/43) to check whether there is any output or not. But there has to be a more elegant way?