Python next() function

The next() function in Python retrieves the next item from the iterator. 

Syntax

Parameter

iterable: It is a required parameter which represents an iterable object.

default: This parameter represents a default value to return if the iterable has reached to its end.

Return

This function returns the next item in an iterator.

Example 1

Output

Example 2

Output

 

Pin It on Pinterest

Share This