EN
Python - remove suffix from string
0
points
In this article, we would like to show you how to remove suffix from the string in Python.
Quick solution:
text = "ABC"
text = text.removesuffix("C")
print("after: ", text) # AB
Practical example
In this example, we use removesuffix()
method to remove suffix substring from the string.
text = "ABC"
print("String before:", text) # ABC
text = text.removesuffix("C")
print("String after: ", text) # AB
Output:
String before: ABC
String after: AB