human
I am working on the file "Iterators and Generators.ipynb".
The first task is:
Use of Generators
1. Easy to Implement
Generators can be implemented in a clear and concise way as compared to their iterator class counterpart.
Can you write Python code for it?
 ... Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.

# Iterator Class
class PowTwo:
    def __init__(self, max = 0):
        self.max = max
    def __iter__(self):
        self.n = 0
        return self
    def __next__(self):
        if self.n > self.max:
            raise StopIteration
        
        result = 2 ** self.n
        self.n += 1
        return result