[python3/en] Added enumerate function (#3601)

* Added enumerate function

* adjusted spacing
This commit is contained in:
Ben Landry 2019-08-13 06:35:13 -04:00 committed by Divay Prakash
parent 555495e4e9
commit 0b5245e2d8

View File

@ -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