Solution 1

``````class NumbersIterator(object):
def __init__(self):
self.next_number = 1

def __iter__(self):
return self

def __next__(self):
number = self.next_number
self.next_number += 1
return number

next = __next__
``````

# Natural Numbers Iterators

Build a simple `NumbersIterator` that iterates over natural numbers starting in 1. Example of usage:

``````iterator = iter(NumbersIterator())

print(next(iterator))  # 1
print(next(iterator))  # 2
print(next(iterator))  # 3
print(next(iterator))  # 4
``````

Warning! This is an infinite iterator. Natural numbers go on forever.

### Test Cases

test natural numbers -

``````def test_natural_numbers():
iterator = iter(NumbersIterator())

assert next(iterator) == 1
assert next(iterator) == 2
assert next(iterator) == 3
assert next(iterator) == 4
``````
class NumbersIterator(object): def __init__(self): self.next_number = 1 def __iter__(self): return self def __next__(self): pass next = __next__ # iterator = iter(NumbersIterator()) # # print(next(iterator)) # print(next(iterator)) # print(next(iterator))