Python Language Iterables and Iterators What can be iterable

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Iterable can be anything for which items are received one by one, forward only. 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

Generators return iterables:

def foo():  # foo isn't iterable yet...
    yield 1

res = foo()  # ...but res already is


Got any Python Language Question?