Using iterator
The class returned an iterator, we could use a for
loop to iterate over the element.
We tried to run through the iterator again, but it did not print anything. It was exhausted.
from counter import Counter
cnt = Counter()
for c in cnt:
print(c)
for c in cnt:
print(c)
Output:
1
2
3