Chapters
Python114 chapters

ReferenceString methods

str.removesuffix()

Drops an exact suffix if it is there.

Signature

text.removesuffix(suffix)

Parameters

NameMeans
suffixthe 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

See also