Question: what is difference between iterator and generator in python?
Answer: An iterator does not make use of local variables, all it needs is iterable to iterate on. A generator may have any number of 'yield' statements. You can implement your own iterator using a python class; a generator does not need a class in python. ... They are also simpler to code than do custom iterator.