Skip to content
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

NameDescription
objectAn iterable object, or a callable when using the two-argument form.
sentinelOptional 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))

Related entries