python_wiki:list_comprehensions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
python_wiki:list_comprehensions [2018/08/03 00:55]
billdozor [The Code]
python_wiki:list_comprehensions [2019/05/25 23:50] (current)
Line 13: Line 13:
  
 ====== Usage ====== ====== Usage ======
- 
-FIXME -> Fill out list comprehension example and code. 
  
 Using the code snippet.  Using the code snippet. 
Line 30: Line 28:
 ====== The Code ====== ====== The Code ======
  
 +**List Comprehension Syntax**
 +<code python>
 +new_list = [x for x in iterable if filter]
 +</code>
 +
 +\\
 +**List Comprehension Example**
 <code python list-comp.py> <code python list-comp.py>
 #!/usr/bin/python #!/usr/bin/python
Line 43: Line 48:
 </code> </code>
  
-The long way without list comprehensions of the above code is+\\ 
 +The long way **without list comprehensions** of the above code is
 <code python> <code python>
 #!/usr/bin/python #!/usr/bin/python
  • python_wiki/list_comprehensions.1533272103.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)