Skip to content

Commit d556714

Browse files
authored
Update programming.rst
I added the words `signed numbers` to cover zero, positive numbers and negative numbers in the section **What’s a negative index?**.
1 parent bcced02 commit d556714

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Doc/faq/programming.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,12 +1176,11 @@ is a list, it makes a copy just like ``seq[:]`` would.
11761176
What's a negative index?
11771177
------------------------
11781178

1179-
Python sequences are indexed with positive numbers and negative numbers. For
1180-
positive numbers 0 is the first index 1 is the second index and so forth. For
1181-
negative indices -1 is the last index and -2 is the penultimate (next to last)
1182-
index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``.
1179+
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
1180+
negative indices, -1 is the last index, -2 is the penultimate (next to last)
1181+
index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``.
11831182

1184-
Using negative indices can be very convenient. For example ``S[:-1]`` is all of
1183+
Using negative indices can be very convenient. For example ``S[:-1]`` is all of
11851184
the string except for its last character, which is useful for removing the
11861185
trailing newline from a string.
11871186

0 commit comments

Comments
 (0)