?
Which built-in Python function is used to create an iterator from an iterable?
Answer & Solution
Correct Answer:
Option
B
The correct answer is Option B: iter().
The iter() function is used to create an iterator from an iterable object in Python. When called with an iterable object as its argument, such as a list, tuple, or string, iter() returns an iterator object that can be iterated over using a for loop or by calling the next() function. This allows for easy iteration over the elements of the iterable, one at a time, using the iterator protocol.
The iter() function is used to create an iterator from an iterable object in Python. When called with an iterable object as its argument, such as a list, tuple, or string, iter() returns an iterator object that can be iterated over using a for loop or by calling the next() function. This allows for easy iteration over the elements of the iterable, one at a time, using the iterator protocol.
Join the Discussion
Login to post a comment or share your explanation.
Login