How to Use iter() Function in PythonPython Basics


The iter() function returns the iterator object.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

x = iter(["A", "B", "C","D","E","F"])
for i in iter(x):
    print(i)

Output:

A
B
C
D
E
F

Syntax

iter(object)

Parameters

Name Description
object An iterable object

Return Value

It returns an iterator object.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us