Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-106318: Add example for str.rindex() method#143887
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
8661e67140d99b08a4a43df2492e8fdfe10File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2163,6 +2163,8 @@ expression support in the :mod:`re` module). | ||
| .. doctest:: | ||
| >>> 'spam, spam, spam'.index('spam') | ||
| 0 | ||
| >>> 'spam, spam, spam'.index('eggs') | ||
| Traceback (most recent call last): | ||
| File "<python-input-0>", line 1, in <module> | ||
| @@ -2546,6 +2548,20 @@ expression support in the :mod:`re` module). | ||
| Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not | ||
| found. | ||
| For example: | ||
| .. doctest:: | ||
| >>> 'spam, spam, spam'.rindex('spam') | ||
| 12 | ||
| >>> 'spam, spam, spam'.rindex('eggs') | ||
Member 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. Can you add a successful example, like looking for ContributorAuthor 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. Sure. But I did it this way to be in line with Should I add it there as well? Member 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.
Yes, I suggest to also add a successful example in str.index(). Try to use the same input string for both examples. ContributorAuthor 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. Done here. Member 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. You didn't add a successful example to str.index(). ContributorAuthor 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. It is a new PR:#144408 Member 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. It doesn't deserve a whole new PR. Please change it in this PR. ContributorAuthor 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. All done. | ||
| Traceback (most recent call last): | ||
| File "<stdin-0>", line 1, in <module> | ||
| 'spam, spam, spam'.rindex('eggs') | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ | ||
| ValueError: substring not found | ||
| See also :meth:`index` and :meth:`find`. | ||
| .. method:: str.rjust(width, fillchar=' ', /) | ||
Uh oh!
There was an error while loading.Please reload this page.