.strip() removes all characters that you provided on both sides, if the string ends with "y" and you strip "germany", which contains "y", "y" is removed. Instead use str.removeprefix() Answer from lukajda33 on reddit.com
🌐
W3Schools
w3schools.com › python › ref_string_strip.asp
Python String strip() Method
Python Examples Python Compiler ... Interview Q&A Python Bootcamp Python Training ... The strip() method removes any leading, and trailing whitespaces....
🌐
Reddit
reddit.com › r/learnpython › how does the strip() method really work?
r/learnpython on Reddit: How does the strip() method really work?
May 3, 2023 -

I want to strip a certain word off of a string. I tried doing this.

string= "Germany Income and Capital Tax Treaty"
string = string.lower().strip('germany')
print(string)

I expected to get:"income and capital tax treaty"

Instead I get"income and capital tax treat"

What is it that I do not understand. Also lstrip and rstrip would not provide a solution as I am writing this in a function where a complete match with the word would need to get stripped off of 'either' end.

Any help?

How does strip() method work for Python Strings? Dec 28, 2018
r/learnpython
7y ago
ELI5 strip method Sep 7, 2019
r/learnpython
6y ago
How to strip a list of characters from a input Oct 31, 2019
r/learnpython
6y ago
int(raw_input().strip()) Jul 26, 2022
r/learnpython
3y ago
.lstrip() will strip extra letters? Jun 2, 2023
r/learnpython
3y ago
More results from reddit.com
🌐
Mimo
mimo.org › glossary › python › string-strip
Python string.strip(): Syntax, Usage, and Examples
The Python string.strip() method cleans unwanted characters from both ends of a string, making your data ready for comparison, storage, or display.
🌐
Python
docs.python.org › 3.4 › library › stdtypes.html
4. Built-in Types — Python 3.4.10 documentation
>>> ' spacious '.strip() 'spacious' >>> 'www.example.com'.strip('cmowz.') 'example'
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-strip
Python String strip() Method - GeeksforGeeks
4 weeks ago - DSA Python · Data Science · NumPy · Pandas · Practice · Django · Flask · Last Updated : 1 Jul, 2026 · strip() method removes specified characters from both the beginning and the end of a string.
Find elsewhere
🌐
Great Learning
mygreatlearning.com › blog › it/software development › strip() function in python with examples
Strip() Function in Python with Examples
November 6, 2023 - By default, the strip() method helps to remove whitespaces from the start and the end of the string. Python's strip() method is a string operation that is used to remove specific characters from both the beginning and the end of a string.
🌐
YouTube
youtube.com › watch
Make text processing easier with .strip() - YouTube
This is a preview of the video course, "Strip Characters From a Python String". By default, Python’s .strip() method removes whitespace characters from both ...
Published   September 25, 2025
🌐
Codecademy
codecademy.com › docs › python › strings › .strip()
Python | Strings | .strip() | Codecademy
April 23, 2025 - The .strip() method, when used without arguments, removes all these whitespace characters from both ends of a string. Preview: Anonymous contributor 36 total contributions ... Looking for an introduction to the theory behind programming?
🌐
Real Python
realpython.com › python-strip
How to Strip Characters From a Python String – Real Python
February 4, 2025 - By default, Python’s .strip() method removes whitespace characters from both ends of a string. To remove different characters, you can pass a string as an argument that specifies a set of characters to remove.
🌐
Hyperskill
hyperskill.org › university › python › strip-in-python
Python strip(), lstrip(), rstrip(): Remove Whitespace & Characters
June 5, 2026 - The Python strip() function is a tool that clears out any extra characters at the beginning and end of a string. Its commonly used to get rid of spaces.
🌐
Python
docs.python.org › 3.6 › library › stdtypes.html
4. Built-in Types — Python 3.6.15 documentation
>>> comment_string = '#....... Section 3.2.1 Issue #32 .......' >>> comment_string.strip('.#! ') 'Section 3.2.1 Issue #32'
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › str › strip.html
strip — Python Reference (The Right Way) 0.1 documentation
>>> ' spacious '.strip() 'spacious' >>> "AABAA".strip("A") 'B' >>> "ABBA".strip("AB") '' >>> "ABCABBA".strip("AB") 'C'
🌐
Python.org
discuss.python.org › python help
.strip function not working in VS code (python) - Python Help - Discussions on Python.org
July 30, 2023 - I’m trying to get rid of whitespace in my code. Ex: name = name.strip() It initially worked but now it is refusing to work. Is this a path issue? I’m a beginner and I’m lost.
🌐
Programiz
programiz.com › python-programming › methods › string › strip
Python String strip()
The strip() method removes any leading (starting) and trailing (ending) whitespaces from a given string. In this tutorial, we will learn about the Python string strip() method with the help of examples.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.6 documentation
The chars argument is not a suffix; rather, all combinations of its values are stripped. For example: >>> ' spacious '.rstrip() ' spacious' >>> 'mississippi'.rstrip('ipz') 'mississ' See removesuffix() for a method that will remove a single suffix string rather than all of a set of characters. For example: >>> 'Monty Python'.rstrip(' Python') 'M' >>> 'Monty Python'.removesuffix(' Python') 'Monty'
🌐
Epic Zoe
yvonnezoe.wordpress.com › 2013 › 05 › 07 › python-strip-method
Python .strip() method | Epic Zoe
May 7, 2013 - The most significant byte is on the right. e.g FF00 – FF is least significant byte and 00 is most significant byte. The data that i would like to display is only the “ss” part. So, to extract “ss” from the readlines reply, the method str.strip(chars) is used.
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › python string strip() method
Python String strip() Method: Syntax, Examples, and Use Cases
March 29, 2026 - The strip function Python provides is used for cleaning the ends of a single string, whereas split() is used for breaking a string into multiple parts. strip(): Removes leading and trailing characters and returns a new string.
🌐
YouTube
youtube.com › watch
What Does Strip Do In Python - YouTube
In this python tutorial, I answer the question of what does strip do in python? I'll walk you through the several ways you can use strip in python and how it...
Published   May 6, 2024