This is an old revision of the document!
List Comprehensions
General Information
List comprehensions are a way to create lists based on lists.
They cut out a step in which you would create an intermediate list just to create a new list.
Checklist
- Python 2 or 3
Usage
→ Fill out list comprehension example and code.
Using the code snippet.
chmod +x list-comp.py ./list-comp.py # Example output ('The tuple is: ', ('centos', 'ubuntu', 'fedora', 'windows', 'arch', 'freebsd')) ('The nix os list is: ', ['centos', 'ubuntu', 'fedora', 'arch', 'freebsd'])
The Code
- program-name.py
Program code here