Python iter() Function
Description
iter() The function is used to generate an iterator.
Syntax
The following is the syntax of the iter() method:
iter(object[, sentinel])
Parameters
- object -- an iterable collection object.
- sentinel -- if a second argument is passed, the object parameter must be a callable object (such as a function). In this case, iter creates an iterator object, and each time the iterator's __next__() method is called, object is called.
Return Value
An iterator object.
Example
lst
=
[
1
,
2
,
3
]
for
i
in
iter
(
lst
)
: ...
(
i
)
...
1
2
3
Python built-in function