How using next() with a generator expression simulates a break statement in a for loop? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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 Antwort
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