Differences
This shows you the differences between two versions of the page.
python_wiki:list_comprehensions [2018/08/03 00:52] billdozor [Usage] |
python_wiki:list_comprehensions [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 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 ====== | ||
- | |||
- | FIXME -> Fill out list comprehension example and code. | ||
- | |||
- | Using the code snippet. | ||
- | <code bash> | ||
- | chmod +x list-comp.py | ||
- | ./ | ||
- | |||
- | # Example output | ||
- | ('The tuple is: ', (' | ||
- | ('The nix os list is: ', [' | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ====== The Code ====== | ||
- | |||
- | <code python program-name.py> | ||
- | Program code here | ||
- | </ | ||
- | |||
- | ---- | ||