In [1]:
import itertools
In [2]:
for i in itertools.count():
print(i)
if i > 3:
break
In [3]:
for i in itertools.count(2):
print(i)
if i > 3:
break
In [4]:
for i in itertools.count(step=3):
print(i)
if i > 8:
break
In [5]:
for i in itertools.count(2, 3):
print(i)
if i > 8:
break
In [6]:
for i in itertools.count(10, -1):
print(i)
if i < 8:
break
In [7]:
for i in itertools.count(0.1, 1.5):
print(i)
if i > 3:
break
In [8]:
for i in itertools.count():
ii = 0.1 + 1.5 * i
print(ii)
if ii > 3:
break
In [9]:
l1 = ['a', 'b', 'c']
l2 = ['x', 'y', 'z']
In [10]:
print(list(zip(itertools.count(), l1, l2)))
In [11]:
print(list(enumerate(zip(l1, l2))))