How usingĀ next()Ā with a generator expression simulates aĀ breakĀ statement in a for loop? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Resposta
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