Skip to content

Commit 5bd5b9d

Browse files
committed
Issue 28587: list.index documentation missing start and stop arguments. (Contributed by Mariatta Wijaya.)
1 parent 5cb0c09 commit 5bd5b9d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Doc/tutorial/datastructures.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,16 @@ objects:
6060
Remove all items from the list. Equivalent to ``del a[:]``.
6161

6262

63-
.. method:: list.index(x)
63+
.. method:: list.index(x[, start[, end]])
6464
:noindex:
6565

66-
Return the index in the list of the first item whose value is *x*. It is an
67-
error if there is no such item.
66+
Return zero-based index in the list of the first item whose value is *x*.
67+
Raises a :exc:`ValueError` if there is no such item.
68+
69+
The optional arguments *start* and *end* are interpreted as in the slice
70+
notation and are used to limit the search to a particular subsequence of
71+
*x*. The returned index is computed relative to the beginning of the full
72+
sequence rather than the *start* argument.
6873

6974

7075
.. method:: list.count(x)
@@ -103,6 +108,8 @@ An example that uses most of the list methods::
103108
[66.25, 333, -1, 333, 1, 1234.5, 333]
104109
>>> a.index(333)
105110
1
111+
>>> a.index(333, 2) # search for 333 starting at index 2
112+
2
106113
>>> a.remove(333)
107114
>>> a
108115
[66.25, -1, 333, 1, 1234.5, 333]

0 commit comments

Comments
 (0)