Python string removesuffix() method
Remove some text from the end, if it is there.
Syntax
str.removesuffix(suffix)
Parameters
| suffix | the text to remove |
Return value
str
Example
Code
print("report.csv".removesuffix(".csv")) print("report.txt".removesuffix(".csv"))
Output
report report.txt
Related
Learn it step by step in the free lesson Strings, with exercises that check your answers.