How can this program be converted to repeat using itertools and terminate definitely | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How can this program be converted to repeat using itertools and terminate definitely

from itertools import cycle, count states=["Kogi","Niger","Lagos"] for i in cycle(states): print(i)

8th Jan 2020, 10:12 AM
Idris Shola A.
2 Antworten
+ 1
Tibor Santa . Many thanks.
8th Jan 2020, 11:54 AM
Idris Shola A.
0
from itertools import cycle, count states=["Kogi","Niger","Lagos"] for c, i in zip(count(), cycle(states)): print(i) if c > 20: break
8th Jan 2020, 10:44 AM
Tibor Santa
Tibor Santa - avatar