Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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.

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

@skirpichev skirpichev Oct 16, 2025

Choose a reason for hiding this comment

The 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 i is relative to the end of sequence, i.e.: len(seq) + i is substituted.


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

Choose a reason for hiding this comment

The 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.

Expand Down
Loading