YouTip LogoYouTip

Python Func Iter

# Python2.x Python iter() Function [![Image 3: Python Built-in Functions](#) Python Built-in Functions](#) * * * ## Description The **iter()** function is used to create an iterator. ### Syntax Here is the syntax for the iter() method: iter(object[, sentinel]) ### Parameters * object -- A collection object that supports iteration. * sentinel -- If a second parameter is passed, then the object parameter must be a callable object (e.g., a function). In this case, iter creates an iterator object, and each time the iterator's __next__() method is called, it will call object. Open mode ### Return Value An iterator object. ### Example >>>lst = [1, 2, 3]>>>for i in iter(lst): ... print(i) ... 1 2 3 [![Image 4: Python Built-in Functions](#) Python Built-in Functions](#)
← Python Func BytearrayPython Func Print β†’