this example defines an capitaliterable class whose job is to loop over each of the words in string and output them with the first letter capitalized most of the work of that iterable is passed to the capitaliterator implementation the canonical way to interact with this iterator is as followsiterable capitaliterable('the quick brown fox jumps over the lazy dog'iterator iter(iterablewhile truetryprint(next(iterator)except stopiterationbreak the quick brown fox jumps over the lazy dog this example first constructs an iterable and retrieves an iterator from it the distinction may need explanationthe iterable is an object with elements that can be looped over normallythese elements can be looped over multiple timesmaybe even at the same time or in overlapping code the iteratoron the other handrepresents specific location in that iterablesome of the items have been consumed and some have not two different iterators might be at different places in the list of wordsbut any one iterator can mark only one place each time next(is called on the iteratorit returns another token from the iterablein order eventuallythe iterator will be exhausted (won' have any more elements to return)in which case stopiteration is raisedand we break out of the loop