In this article, you will see how to remove string from both sides in Python. The
strip() method removes all leading and trailing characters (characters at the beginning and at the end of a string) that match the characters specified in its argument.
Step 1: Create a string
str = "CodeAllow" print("str = ", str) print("str type = ", type(str))
Step 2: Remove string from both sides
print("Removed = ", str.strip("CodeAllow"))
str = CodeAllow str type = <class 'str'> Removed =
Free resources to learn advanced skills: AiHints and CodeAllow