What can be iterable

suggest change

Iterable can be anything from which items are received one by one. Built-in collections can be iterated again. A generator is forward-only and is spent after one pass. Built-in Python collections are iterable:

[1, 2, 3]     # list, iterate over items
(1, 2, 3)     # tuple
{1, 2, 3}     # set
{1: 2, 3: 4}  # dict, iterate over keys

A generator function returns a generator iterator, which is iterable:

def foo():  # the function itself is not an iterator
    yield 1

res = foo()  # res is a generator iterator

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents