summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen Landry <Blandry1@users.noreply.github.com>2019-08-13 06:35:13 -0400
committerDivay Prakash <divayprakash@users.noreply.github.com>2019-08-13 16:05:13 +0530
commit0b5245e2d83453f23e13195ea164a35603c4855a (patch)
tree1ba218749b93bed09b0b8d4de683ee8e19f6f550
parent555495e4e9cb0b7d2fe8542737972ed8aa82f3bf (diff)
[python3/en] Added enumerate function (#3601)
* Added enumerate function * adjusted spacing
-rw-r--r--python3.html.markdown11
1 files changed, 11 insertions, 0 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index ecdbd932..ef78ce37 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -462,8 +462,19 @@ prints:
"""
for i in range(4, 8, 2):
print(i)
+
+"""
+To loop over a list, and retrieve both the index and the value of each item in the list
+prints:
+ 0 dog
+ 1 cat
+ 2 mouse
"""
+list = ["dog", "cat", "mouse"]
+for i, value in enumerate(list):
+ print(i, value)
+"""
While loops go until a condition is no longer met.
prints:
0