explicit attributes and methodsextra structureinheritance hierarchiesand support for multiple behaviors may be better suited for richer use cases of coursefor this artificial exampleyou could in fact skip both techniques and simply use for loopmapor list comprehension to build the list all at once barring performance data to the contrarythe best and fastest way to accomplish task in python is often also the simplest[ * for in range( )[ howeverclasses may be better at modeling more complex iterationsespecially when they can benefit from the assets of classes in general an iterable that produces items in complex database or web service resultfor examplemight be able to take fuller advantage of classes the next section explores another use case for classes in userdefined iterables multiple iterators on one object earlieri mentioned that the iterator object (with __next__produced by an iterable may be defined as separate class with its own state information to more directly support multiple active iterations over the same data consider what happens when we step across built-in type like strings 'acefor in sfor in sprint( yend='aa ac ae ca cc ce ea ec ee herethe outer loop grabs an iterator from the string by calling iterand each nested loop does the same to get an independent iterator because each active iterator has its own state informationeach loop can maintain its own position in the stringregardless of any other active loops moreoverwe're not required to make new string or convert to list each timethe single string object itself supports multiple scans we saw related examples earlierin and for instancegenerator functions and expressionsas well as built-ins like map and zipproved to be singleiterator objectsthus supporting single active scan by contrastthe range built-inand other built-in types like listssupport multiple active iterators with independent positions when we code user-defined iterables with classesit' up to us to decide whether we will support single active iteration or many to achieve the multiple-iterator effect__iter__ simply needs to define new stateful object for the iteratorinstead of returning self for each iterator request iterable objects__iter__ and __next__