Untitled
unknown
python
3 years ago
479 B
8
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...