5 Iterables and iterations
This chapter covers
- Understanding iterables and iterators
- Creating common data containers using iterables
- Using list, dictionary, and set comprehensions for instantiation
- Improving for-loop iterations
- Using continue, break, and else in for and while loops
Previous chapters mentioned iterables several times, and we know that lists, tuples, and many other built-in data types are iterables. But we haven’t explicitly defined the concept of iterables. We say that these data types are iterables, but we haven’t discussed why. In this chapter, you’ll find out how they constitute iterables. More importantly, we’ll explore how we can create the most common data models, such as lists and dictionaries, from other iterables by ...
Get Python How-To now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.