mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
Merge pull request #292 from mattboehm/master
Fix enumerate code snippet to run without error message
This commit is contained in:
@@ -548,11 +548,11 @@ keep a count of your place in the list.
|
||||
.. code-block:: python
|
||||
|
||||
for i, item in enumerate(a):
|
||||
print i + ", " + item
|
||||
print i, item
|
||||
# prints
|
||||
# 0, 3
|
||||
# 1, 4
|
||||
# 2, 5
|
||||
# 0 3
|
||||
# 1 4
|
||||
# 2 5
|
||||
|
||||
The ``enumerate`` function has better readability than handling a counter
|
||||
manually. Moreover,
|
||||
|
||||
Reference in New Issue
Block a user