Posted on 28th March 2024
There is an alternative for StopIteration by utilising next(iteration, default_value)
Example:
>>> a = iter('hey')
>>> print next(a, None)
h
>>> print next(a, None)
e
>>> print next(a, None)
y
>>> print next(a, None)
None
STILL GOT QUERIES?