ReferenceString methods
str.removeprefix()
Drops an exact prefix if it is there, and leaves the string alone if not.
Signature
text.removeprefix(prefix)Parameters
| Name | Means |
|---|---|
prefix | the exact text to remove from the start |
Returns
A new string.
Example
Python
print("www.example.com".removeprefix("www."))
print("example.com".removeprefix("www."))Output
example.com example.com