ReferenceString methods
str.removesuffix()
Drops an exact suffix if it is there.
Signature
text.removesuffix(suffix)Parameters
| Name | Means |
|---|---|
suffix | the exact text to remove from the end |
Returns
A new string.
Example
Python
print("report.pdf".removesuffix(".pdf"))
print("report".removesuffix(".pdf"))Output
report report