From d55671477a4c6e79da5e9f9e741d8fb6e058b589 Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Thu, 16 Oct 2025 03:08:26 +0900 Subject: [PATCH 1/2] Update programming.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I added the words `signed numbers` to cover zero, positive numbers and negative numbers in the section **What’s a negative index?**. --- Doc/faq/programming.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 6f9dfa8616ed44..cb17078b73c646 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -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 (0, 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]``. -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 the string except for its last character, which is useful for removing the trailing newline from a string. From 8d989c04e4de8d6d9b9260133df81067e52bba97 Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Thu, 16 Oct 2025 03:22:10 +0900 Subject: [PATCH 2/2] Update programming.rst --- Doc/faq/programming.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index cb17078b73c646..b279165bd707ed 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1176,7 +1176,7 @@ is a list, it makes a copy just like ``seq[:]`` would. What's a negative index? ------------------------ -Python sequences are indexed with signed numbers (0, 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 +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]``.