mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
[python3/en] Added enumerate function (#3601)
* Added enumerate function * adjusted spacing
This commit is contained in:
parent
555495e4e9
commit
0b5245e2d8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user