Skip to content

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

Open
@cmjzzx

Description

@cmjzzx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions