How to use repeat() and count() to repeat and enumerate a value in Python

1 Answer

0 votes
from itertools import *     

for i, val in zip(count(), repeat('python', 3)):         
     print(i, val)



'''
run:
 
0 python
1 python
2 python

'''

 



answered May 21, 2019 by avibootz
edited May 21, 2019 by avibootz

Related questions

1 answer 173 views
1 answer 186 views
3 answers 191 views
1 answer 180 views
...