Here we have a string iterated by a for loop:

Below is how it was done:

When it goes past the last element, it raises an StopIteration exception (which is handled gracefully by the for loop).