The comments in the python-for-beginners/12 - Loops/number.py file contain inaccuracies about the range function in Python.
Details:
In the file number.py, the comment states:
# range creates an array
# First parameter is the starter
# Second indicates the number of numbers to create
# range(0, 2) creates [0, 1]
This is incorrect because:
range does not create an array; it creates a range object.
The second parameter of range specifies the end value (exclusive), not the number of values to create.
range(0, 2) does indeed create [0, 1], but the comment should clarify that the second parameter is the end value, not the count of numbers.
Suggested Correction:
Update the comments in number.py to accurately describe the range function. For example:
# range creates a range object, not an array
# The first parameter is the starting value
# The second parameter is the ending value (not included in the sequence)
# range(0, 2) creates a sequence [0, 1]
Issue:
The comments in the
python-for-beginners/12 - Loops/number.py
file contain inaccuracies about therange
function in Python.Details:
In the file
number.py
, the comment states:This is incorrect because:
range
does not create an array; it creates arange
object.range
specifies the end value (exclusive), not the number of values to create.range(0, 2)
does indeed create[0, 1]
, but the comment should clarify that the second parameter is the end value, not the count of numbers.Suggested Correction:
Update the comments in
number.py
to accurately describe therange
function. For example:File Path:
python-for-beginners/12 - Loops/number.py
Thank you for addressing this issue.