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 182 views
1 answer 190 views
3 answers 209 views
1 answer 189 views
...