mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Add step parameter to range function
A description of the step parameter of the range function is added. An example of its use in a for loop is also given.
This commit is contained in:
parent
9b46fe7e57
commit
82bdd1b1c8
@ -352,6 +352,18 @@ for i in range(4, 8):
|
||||
print(i)
|
||||
|
||||
"""
|
||||
"range(lower, upper, step)" returns an iterable of numbers
|
||||
from the lower number to the upper number, while incrementing
|
||||
by step. If step is not indicated, the default value is 1.
|
||||
prints:
|
||||
4
|
||||
6
|
||||
8
|
||||
"""
|
||||
for i in range(4, 8, 2):
|
||||
print(i)
|
||||
"""
|
||||
|
||||
While loops go until a condition is no longer met.
|
||||
prints:
|
||||
0
|
||||
|
Loading…
Reference in New Issue
Block a user