How to use an iterator?
fl
rxjwg98 at gmail.com
Mon Jun 1 21:26:57 EDT 2015
Hi,
I read the online tutorial on iterator:
https://docs.python.org/2/library/itertools.html
I have no idea on how to use this one:
itertools.count(start=0, step=1)
BTW, I am using Python 2.7.9 on Windows 7.
I even input the following:
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
>>> xc=count(10)
>>> xc
<generator object count at 0x02BA9AD0>
How to use this generator?
Thanks,
More information about the Python-list
mailing list