Question:

Write a iterator function to work like xrange()

Program:

Explanation:

The iterator protocol consists of two methods. The __iter__() method, which must return the iterator object and the next() method, which returns the next element from a sequence. Python has several built-in objects, which implement the iterator protocol. For example lists, tuples, strings, dictionaries or files.

Output:

 

Leave a Reply

bodrum escort - eskişehir esc - mersin escort - mersin escort bayan - mersin esc