Function Details: iter

Description


Returns an iterator object.


Extended Description


The iter() function returns an iterator object. It can be called in two ways: with a single iterable argument, or with a callable and a sentinel. When called with a single argument, the argument must be iterable. When called with two arguments, the first must be callable and is called until it returns the sentinel value.


Read More about iter from Python Documentation

Function Signature


iter(object: Union[Iterable, Callable], sentinel: Optional[Any] = None) -> iterator

Module: builtins

Parameters



Parameter List


  • object: Union[Iterable, Callable]
  • sentinel: Optional[Any]

Return


Returns an iterator object.


Return Type


iterator

Output

Explanation

This example demonstrates basic usage of iter() with a list and how to use next() to iterate through it.