EN
Python - remove prefix from string
0 points
In this article, we would like to show you how to remove prefix from the string in Python.
Quick solution:
xxxxxxxxxx
1
text = "ABC"
2
text = text.removeprefix("A")
3
print("after: ", text) # BC
In this example, we use removeprefix()
method to remove prefix substring from the string.
xxxxxxxxxx
1
text = "ABC"
2
print("String before:", text) # ABC
3
4
text = text.removeprefix("A")
5
print("String after: ", text) # BC
Output:
xxxxxxxxxx
1
String before: ABC
2
String after: BC