mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
Fix list manipulation comments and for loop
This commit is contained in:
@@ -215,12 +215,12 @@ operations on lists using a different concise syntax.
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Filter elements less than 5
|
# Filter elements greater than 4
|
||||||
a = [3, 4, 5]
|
a = [3, 4, 5]
|
||||||
b = []
|
b = []
|
||||||
for i in a:
|
for i in a:
|
||||||
if a > 4:
|
if i > 4:
|
||||||
b.append(a)
|
b.append(i)
|
||||||
|
|
||||||
**Good**:
|
**Good**:
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ keep a count of your place in the list.
|
|||||||
|
|
||||||
for i, item in enumerate(a):
|
for i, item in enumerate(a):
|
||||||
print i + ", " + item
|
print i + ", " + item
|
||||||
# prints
|
# prints
|
||||||
# 0, 3
|
# 0, 3
|
||||||
# 1, 4
|
# 1, 4
|
||||||
# 2, 5
|
# 2, 5
|
||||||
|
|||||||
Reference in New Issue
Block a user