Languages
[Edit]
EN

Python - remove prefix from string

0 points
Created by:
Molly
201

In this article, we would like to show you how to remove prefix from the string in Python.

Quick solution:

text = "ABC"
text = text.removeprefix("A")
print("after: ", text)  # BC

 

Practical example

In this example, we use removeprefix() method to remove prefix substring from the string.

text = "ABC"
print("String before:", text)  # ABC

text = text.removeprefix("A")
print("String after: ", text)  # BC

Output:

String before: ABC
String after:  BC

Python - string (popular problems)

Python - remove prefix from string
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join