A list comprehension is a way to construct a list in Python using a single line of code. The pattern of creating an empty list, setting up a for loop, and then using several if-then clauses to determine which data should appear in the list can all be done in a single line in Python.
Stay tuned! Bonus features for this video are under development...
Our Python Tutorials will help you learn Python quickly and thoroughly. We start with "Hello World" and then move on to data structures (sets, lists, tuples and dictionaries). Next we'll cover classes, and give a variety of in-depth examples and applications.