How using next() with a generator expression simulates a break statement in a for loop? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How using next() with a generator expression simulates a break statement in a for loop?

I understood that it works but can anyone explain the logic behind how it works?

7th Sep 2017, 6:01 AM
Jeevan Jyoti
Jeevan Jyoti - avatar
1 Respuesta
0
i dont know exactly what you mean, calling next(a) (a ofcourse being a generator) while iterating through it does not break the loop which is iterating through it... could you give me some example code?
28th Sep 2017, 3:19 PM
Philippe Dumonet
Philippe Dumonet - avatar