Python : Generator raised StopIteration - Why? and Solution

Опубликовано: 27 Октябрь 2024
на канале: Letzz Doo IT
63
1

Any return statement inside a generator will raise StopIteration. However, the exceptions raised by return cannot be caught via try, except blocks within that particular generator itself. It can be caught anywhere else other than the generator that is being returned.