What are Python Iterators ?
                  An iterator in Python is an object that allows you to iterate (loop) through elements one at a time.

An iterator must follow the iterator protocol, which means it must have:

 __iter__( ) method → returns iterator object
 __next__( ) method → returns next value


Iterator vs Iterable :
An object is iterable if it can return an iterator. Some of the iterables are lists, tuples, string, set, dictionary .
                  But these are not iterators by default -  they only return iterators.

                  To convert an iterable into an iterator, we use:

Python
iter(object) 


Convert List to Iterator :

Python
numbers = [10, 20, 30] it = iter(numbers) print(next(it)) print(next(it)) print(next(it)) #output 10 20 30 

Custom Iterator :
Python
class CountDown: def __init__(self, start): self.num = start def __iter__(self): return self def __next__(self): if self.num <= 0: raise StopIteration value = self.num self.num -= 1 return value cd = CountDown(3) for n in cd: print(n) #output 3 2 1