You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/string-methods/about.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,7 @@ Just the place for a Snark! I have said it thrice:
119
119
120
120
Python `3.9` introduces two new string methods that make removing prefixes and suffixes much easier.
121
121
122
-
[`<str>.removeprefix(<substring>)`](https://docs.python.org/3.9/library/stdtypes.html#str.removeprefix) return the string without the prefix (`string[len(<substring>):]`), if the `<substring>` isn't present it will return a copy of the original string.
122
+
[`<str>.removeprefix(<substring>)`][removeprefix] returns the string without the prefix (`string[len(<substring>):]`). If the `<substring>` isn't present, a copy of the original string will be returned.
123
123
124
124
```python
125
125
# removing a prefix
@@ -129,7 +129,7 @@ Python `3.9` introduces two new string methods that make removing prefixes and s
129
129
'bookkeeper'
130
130
```
131
131
132
-
[`<str>.removesuffix(<substring>)`](https://docs.python.org/3.9/library/stdtypes.html#str.removesuffix) return the string without the suffix (`string[:-len(substring)]`), if the `<substring>` isn't present it will return a copy of the original string.
132
+
[`<str>.removesuffix(<substring>)`][removesuffix] returns the string without the suffix (`string[:-len(substring)]`). If the `<substring>` isn't present, a copy of the original string will be returned.
133
133
134
134
```python
135
135
# removing a suffix
@@ -159,3 +159,7 @@ Python also supports regular expressions via the `re` module, which will be cove
0 commit comments