Python iter() Function
Example
Create an iterator object and print the items:
x = iter(["apple", "banana", "cherry"]) print(next(x)) print(next(x)) print(next(x))
Definition and Usage
iter() returns an iterator object.
Syntax
iter(object, sentinel)
Parameter Value
Parameter | Description |
---|---|
object | Required. An iterable object. |
sentinel | Optional. If the object is a callable object, the iteration will stop when the return value is the same as the sentinel. |
Related Pages
Reference Manual:reversed() Function(পাঠ্যসাগরের উল্টো ইটারেটর অবজেক্ট ফিরিয়ে দেয়)