Languages
[Edit]
EN

Python - remove suffix from string

0 points
Created by:
Zachary
406

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
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Python - string (popular problems)

Python - remove suffix 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