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.
To learn Python, you can watch our playlist from the beginning:
Python Cookbook, Third edition from O’Reilly
The Mythical Man Month – Essays on Software Engineering & Project Management
Shop Amazon Used Textbooks – Save up to 90%
Subscribe to Socratica:
This video was made possible with the support of our Patrons on Patreon! We wish to particularly thank our VIP Patron Vishal Shah. Thank you for your generous support, Vishal!
To support more videos from Socratica, visit
We also accept Bitcoin! 🙂
Our address is: 1EttYyGwJmpy9bLY2UcmEqMJuBfaZ1HdG9
Python instructor: Ulka Simone Mohanty
Written & Produced by Michael Harrison
FX by Andriy Kostyuk
The dress worn by the instructor can be purchased at Shenova Fashion: