Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cmjzzx opened this issue Aug 9, 2024 · 2 comments

Comments

@cmjzzx
Copy link

cmjzzx commented Aug 9, 2024

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
Copy link

saiyoji commented Aug 9, 2024 via email

@zjrsss
Copy link

zjrsss commented Aug 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants