#100DaysOfCode in Python Transcripts
Chapter: Days 16-18: List comprehensions and generators
Lecture: Concepts: what did we learn

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's look at what we've learned so far.
0:03 List comprehensions.
0:05 For both ways of doing a loop and conditional,
0:09 we loop over list and store all the modifications
0:12 in a new list.
0:13 Five lines of code.
0:15 The more Pythonic ways to use a list comprehension.
0:19 One line of code.
0:20 And it reads like English.
0:22 We went through another sample cleaning up a word list,
0:25 and you can do multiple checks.
0:28 in the conditional part over list comprehension.
0:32 Secondly, generators.
0:35 The simplest generator would be something like this.
0:39 For in range, yield the value.
0:42 Generators, pause.
0:44 So, after every call it stops at the yield,
0:47 and comes back.
0:50 Use a generator to build up a sequence.
0:53 Here I made a bunch of options for a fictional website.
0:57 And instead of building up a list in the function,
1:01 we use the yield statement
1:02 to just generate a sequence of items.
1:06 And lastly,
1:07 we look at list and generators,
1:12 and we saw that when your data set grows
1:15 your really want to know about generators
1:17 because the items are lazily loaded,
1:20 not taking up the whole memory footprint.
1:23 And that's it for the basics.
1:26 And now it's your turn for day two and three
1:29 to get more practical exercise.