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:
xxxxxxxxxx
1
text = "ABC"
2
text = text.removesuffix("C")
3
print("after: ", text) # AB
In this example, we use removesuffix()
method to remove suffix substring from the string.
xxxxxxxxxx
1
text = "ABC"
2
print("String before:", text) # ABC
3
4
text = text.removesuffix("C")
5
print("String after: ", text) # AB
Output:
xxxxxxxxxx
1
String before: ABC
2
String after: AB