How can this program be converted to repeat using itertools and terminate definitely | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
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 Respostas
+ 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