[docs] [issue23299] Documentation correction - 5.1.4. List Comprehensions
Liang Zhang
report at bugs.python.org
Thu Jan 22 09:53:41 CET 2015
New submission from Liang Zhang:
This was copied from Chapter 5 Data Structure in Python language tutorial.
The link I was looking for: https://docs.python.org/2.7/tutorial/datastructures.html
Some thing might be incorrect and need you to update them in
(5.1.4. List Comprehensions)
It should be like this:
------------------start------------------
>>> vec = [-4, -2, 0, 2, 4]
>>> # create a new list with the values doubled
>>> [x*2 for x in vec]
[-8, -4, 0, 4, 8]
>>> # filter the list to exclude negative numbers
>>> [x for x in vec if x >= 0]
[0, 2, 4]
>>> # apply a function to all the elements
>>> [abs(x) for x in vec]
[4, 2, 0, 2, 4] >>>>>>>>>>>It should be [0, 2, 4]<<<<<<<<<<<
------------------end------------------
----------
assignee: docs at python
components: Documentation
messages: 234485
nosy: Liang.Zhang, docs at python
priority: normal
severity: normal
status: open
title: Documentation correction - 5.1.4. List Comprehensions
type: resource usage
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23299>
_______________________________________
More information about the docs
mailing list