To access the values returned by the iterator, you use the next () method of the iterator as follows:
try:
while True:
val = it.next()
print(val)
except StopIteration:
print("Iteration done.")
next () has the goal of promoting both an iterator and returning the next element. StopIteration is thrown when iteration is performed.
Since this is rather cumbersome, all of this is perfectly complemented by the syntax:
for i in it:
print(i)
print("Iteration done.")
Other links: