Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:59:52+00:00 2026-06-08T23:59:52+00:00

Python 2.7.3 (default, Apr 20 2012, 22:44:07) [GCC 4.6.3] on linux2 Type help, copyright,

  • 0
Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.  

>>> s = "www.example.com/help"
>>> s.strip('/')
>>> 'www.example.com/help'    #expected 'www.example.comhelp'
>>> t = "/blah/blah/"
>>> t.strip('/')
>>> 'blah/blah'    #expected 'blahblah'
>>> s.strip('w.')
>>> 'example.com/help'    #expected 'examplecom/help'
>>> f = 'www.example.com'
>>> f.strip('.')
>>> 'www.example.com'    #expected 'wwwexamplecom'
>>> f.strip('comw.')
>>> 'example'    #as expected

Can someone please explain why str.strip doesn’t seem to work as promised?

From the documentation:

str.strip([chars])

Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:59:54+00:00Added an answer on June 8, 2026 at 11:59 pm

    str.strip([chars])

    Return a copy of the string with the leading and trailing characters removed.

    Use this to replace a string anywhere:

    s.replace('/', '')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type help, copyright,
Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win
I use Python 2.6 more than I use Leopard's default python installation, so I
I am using python default development http server, and it works fine. Error ,The
Do the following on the default Python install on Mac OS X 10.5 (Leopard)
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm finding that dictionary
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm trying to create
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I was working on
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument def f(a, L=[]): L.append(a)
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.