
Hello dears, First of all i am not sure about this issue please advise me if there is any mistake in my report. for example in python 3.6.3 shell:
As you see the letter "e" of the word "life" is removed. Sincerely yours. J.Mohammadi

Hi Jeff, This is the expected way for str.strip to work, see the write-up here: https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip It won't strip the word 'meaning', but it will remove all characters at the end that are in your argument (in thise case: only `e`). Perhaps you are looking for .removesuffix or .replace. Regards, Simon On Wed, May 4, 2022, at 11:36 AM, Jeff Jeffi wrote:

This is exactly as expected. Strip removes any of the characters in the passed string from both the front and the end of the string being stripped. The letter 'T' from the start of 'The meaning of life' does not appear in the word 'meaning' so nothing is removed from the start of the string. The letter 'e' from the end of 'The meaning of life' does appear in the word 'meaning' so it is removed from the sentence; it will then look at the next last letter 'f', but since this doesn't appear in the word 'meaning' nothing else is removed and the new string is returned. The argument passed to strip(..) method is the set of characters to be removed - so any characters in that set are removed from the start and end of the string. ------ Original Message ------ From: "Jeff Jeffi" <infojmail@gmail.com> To: docs@python.org Cc: python-list@python.org Sent: Wednesday, 4 May, 22 At 10:36 Subject: [docs] Reporting a Bug Hello dears, First of all i am not sure about this issue please advise me if there is any mistake in my report. for example in python 3.6.3 shell:
x= "The meaning of life" x.strip("meaning") 'The meaning of lif'
As you see the letter "e" of the word "life" is removed. Sincerely yours. J.Mohammadi _______________________________________________ docs mailing list -- docs@python.org To unsubscribe send an email to docs-leave@python.org https://mail.python.org/mailman3/lists/docs.python.org/ <https://mail.python.org/mailman3/lists/docs.python.org/> Member address: anthony.flury@btinternet.com -- <br>Anthony Flury<br>anthony.flury@btinternet.com

Hi Jeff, This is the expected way for str.strip to work, see the write-up here: https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip It won't strip the word 'meaning', but it will remove all characters at the end that are in your argument (in thise case: only `e`). Perhaps you are looking for .removesuffix or .replace. Regards, Simon On Wed, May 4, 2022, at 11:36 AM, Jeff Jeffi wrote:

This is exactly as expected. Strip removes any of the characters in the passed string from both the front and the end of the string being stripped. The letter 'T' from the start of 'The meaning of life' does not appear in the word 'meaning' so nothing is removed from the start of the string. The letter 'e' from the end of 'The meaning of life' does appear in the word 'meaning' so it is removed from the sentence; it will then look at the next last letter 'f', but since this doesn't appear in the word 'meaning' nothing else is removed and the new string is returned. The argument passed to strip(..) method is the set of characters to be removed - so any characters in that set are removed from the start and end of the string. ------ Original Message ------ From: "Jeff Jeffi" <infojmail@gmail.com> To: docs@python.org Cc: python-list@python.org Sent: Wednesday, 4 May, 22 At 10:36 Subject: [docs] Reporting a Bug Hello dears, First of all i am not sure about this issue please advise me if there is any mistake in my report. for example in python 3.6.3 shell:
x= "The meaning of life" x.strip("meaning") 'The meaning of lif'
As you see the letter "e" of the word "life" is removed. Sincerely yours. J.Mohammadi _______________________________________________ docs mailing list -- docs@python.org To unsubscribe send an email to docs-leave@python.org https://mail.python.org/mailman3/lists/docs.python.org/ <https://mail.python.org/mailman3/lists/docs.python.org/> Member address: anthony.flury@btinternet.com -- <br>Anthony Flury<br>anthony.flury@btinternet.com
participants (3)
-
anthony.flury
-
Jeff Jeffi
-
Simon de Vlieger