Untitled
Anonymous
python
09/28/2022 8:57 PM
640 B
14
Indexable
class CustomerCounter:
def __init__(self, max=5):
self.max = max
def __iter__(self):
self.count = 0
return self
def __next__(self):
self.count += 1
if self.count > self.max:
raise StopIteration
return self.count
customer_counter = CustomerCounter()
i = iter(customer_counter)
print(next(i))
print(next(i))
print(next(i))
print(next(i))
for customer_count in customer_counter:
print(customer_count)Editor is loading...