microsoft / c9-python-getting-started

Sample code for Channel 9 Python for Beginners course
MIT License
7.75k stars 2.24k forks source link

Incorrect Comment About `range` Function in python-for-beginners/12 - Loops/number.py #88

Open cmjzzx opened 1 month ago

cmjzzx commented 1 month ago

Issue:

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:

  1. range does not create an array; it creates a range object.
  2. The second parameter of range specifies the end value (exclusive), not the number of values to create.
  3. 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]

File Path:

python-for-beginners/12 - Loops/number.py

Thank you for addressing this issue.

saiyoji commented 1 month ago

这是来自QQ邮箱的假期自动回复邮件。已收到。

zjrsss commented 1 month ago

您的邮件已收到!祝生活愉快!