List Comprehensions Overview
This lesson gives an overview of list comprehensions and explains what they are good for and how this course will help you to understand them. In later sections of the course, you will see how to transform list comprehensions back into for loops and the other way around. This will help you to see how using them helps make your code easier to read and maintain.
Resources
00:00 In this tutorial, I’m going to talk about list comprehensions. List comprehensions are actually one of my favorite features in Python. I know they can seem a little bit arcane at first or a little bit strange, but they are actually super helpful. They can help make your programs easier to read and easier to maintain, once you’ve actually wrapped your head around how they work.
00:19
And when you break them down to first principles, they are relatively easy to understand. Behind the scenes, it’s pretty much all just for
loops, and that’s what I’m going to teach you in this tutorial.
00:31
I’m going to show you exactly how you can take an existing for
loop in Python and then transform it into a list comprehension, and also do the same thing the other way round. All right, so let’s jump right in!
Become a Member to join the conversation.