-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Correct usage of "positive numbers" in FAQ section "What’s a negative index?". #140176
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1176,12 +1176,11 @@ is a list, it makes a copy just like ``seq[:]`` would. | |
| What's a negative index? | ||
| ------------------------ | ||
|
|
||
| Python sequences are indexed with positive numbers and negative numbers. For | ||
| positive numbers 0 is the first index 1 is the second index and so forth. For | ||
| negative indices -1 is the last index and -2 is the penultimate (next to last) | ||
| index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``. | ||
| Python sequences are indexed with signed numbers (zero, positive numbers and negative numbers). For example, 0 is the 1st index and for positive indices, 1 is the 2nd index, 2 is the 3rd index and so forth. For | ||
| negative indices, -1 is the last index, -2 is the penultimate (next to last) | ||
| index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``. | ||
|
Comment on lines
+1179
to
+1181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that old text was too bad. But you if considered to change that - please use more common terminology. What's "signed numbers" are? Integers, right? You could mention that for non-negative indexes it's meaning is just usual zero-based indexing of arrays. For negative indexes, the index |
||
|
|
||
| Using negative indices can be very convenient. For example ``S[:-1]`` is all of | ||
| Using negative indices can be very convenient. For example ``S[:-1]`` is all of | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this change. |
||
| the string except for its last character, which is useful for removing the | ||
| trailing newline from a string. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines should be wrapped to 79 characters.