From the course: Advanced Python
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Basic iterators - Python Tutorial
From the course: Advanced Python
Basic iterators
- [Instructor] The operation of looping over sequences of values is very common in Python, and there are several built-in methods and modules to help out with this. During this chapter, we're going to investigate several different ways of processing sequences of values. The term we use to describe this processing is called iteration. And in this exercise, we'll start off by using some built-in methods to make iterating over sequences quick and easy. Let's open up the Basic_Iterators file. And here, I have two sequences of day name abbreviations in both English and in French. You're probably already familiar with the for in construct, which you can use to create a loop for a given sequence. So this code just loops over the days list and prints the day to the terminal. So let's go ahead and just run that and just see it in action. And sure enough, if you can see the output right here, the days are being printed out on each line. So there might be times when you want more granular access…
Contents
-
-
-
-
(Locked)
Basic iterators4m 20s
-
(Locked)
More iterators7m 4s
-
(Locked)
For-else3m 37s
-
Itertools: count, cycle, accumulate6m 46s
-
(Locked)
Itertools: chain, chain.from_iterable, batched3m 25s
-
(Locked)
Itertools: dropwhile, takewhile, filterfalse6m 2s
-
(Locked)
Itertools: combinations and permutations6m 5s
-
(Locked)
Solution: Using Iterators1m 10s
-
(Locked)
-
-
-
-