Home » iter() in Python | Python iter() Function with Examples

iter() in Python | Python iter() Function with Examples

by Online Tutorials Library

Python iter() Function

The python iter() function is used to return an iterator object. It creates an object which can be iterated one element at a time.

Signature

Parameters

object: An iterable object.

sentinel (optional)- It is a special value that represents the end of a sequence.

Return

It returns an iterator object.

Python iter() Function Example 1

The below example shows the working of iter().

Output:

1  2  3  4  5  

Explanation: In the above example, iter() function converts an list iterable to an iterator.


Next TopicPython Functions

You may also like