Python – Retrieves Next Element from Iterator – next() Function with Examples

next() function is used to find the the next item from the iterator in Python for the given input.

next() function is a part of Python Built-in Functions.

Syntax of next() Function

The syntax of next() function in Python is:

next(iterator, default)

 

Parameters of next() Function in Python

x – Where x is any valid . This parameter is required.

 

Compatibility

next() function is available and compatible with both Python 2.x and 3.x.

 

Return Value of next() Function in Python

next() function returns the next item from the iterator for the given input.

 

Python next() Function Example 1

Example CODE

Output:

 

Python next() Function Example 2

Example CODE

Output: