Python

Python Menu

Python

Python iter() Function - Definition, Syntax, Parameters, Examples

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))

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods