How can this program be converted to repeat using itertools and terminate definitely | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
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 Réponses
+ 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