A class is its own iterator. Each step drops the last letter of a word.
class Shrink:
def __init__(self, word):
self.word = word
def __iter__(self):
return self
def __next__(self):
if not self.word:
raise StopIteration
self.word = self.word[:-1]
return self.word
c = Shrink("abc")
print(list(c), list(c))
What does the program print?