SyntaxFix
Write A Post
Hire A Developer
Questions
You can tee the iterator using, itertools.tee, and check for StopIteration on the teed iterator.
tee
itertools.tee
StopIteration