Built-in Functions
iter()
Return an iterator for a collection or other iterable.
iter(object, sentinel=None)
iter() creates an iterator that produces one item at a time. You can retrieve its next item with next().
Parameters
| Name | Description |
|---|---|
| object | An iterable object, or a callable when using the two-argument form. |
| sentinel | Optional stopping value for the two-argument callable form. |
Returns
An iterator object.
Try it
Run it and change it
items = ["a", "b"] iterator = iter(items) print(next(iterator))