Definition
The iter() function returns an iterator object.
Syntax
iter(object, sentinel)
Parameters
Parameter | Description |
---|---|
object | Required. An iterable object |
sentinel | Optional. If the object is a callable object the iteration will stop when the returned value is the same as the sentinel |
Examples
fruits = iter(["apple", "orange", "mango"])
print(next(fruits))
print(next(fruits))
print(next(fruits))