Skip to main content

One doc tagged with "iterables"

View all tags

Iterators and Iterables: The Iterator Protocol

One of the most powerful and frequently used features in Python is the for loop. We use it to loop over lists, strings, dictionaries, and files. But how does it actually work? How does the for loop know how to handle all these different types of objects?