How to delete a ast character from a string?

Discussion in 'Python' started by dudeja.rajat@gmail.com, Aug 29, 2008.

  1. Guest

    Hi,

    I've a list some of whose elements with character \.
    I want to delete this last character from the elements that have this
    character set at their end,

    I have written a small program, unfortunately this does not work:

    dirListFinal = []
    for item in dirList:
    print item
    if item.endswith('\\') == True:
    item = item[0:-1] # This one I googled and
    found to remove the last character /
    dirListFinal.append(item)
    else:
    dirListFinal.append(item)


    item.endswith() does not seem to be working.

    Please help
    --
    Regrads,
    Rajat
     
    , Aug 29, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brand Bogard

    8 bit character string to 16 bit character string

    Brand Bogard, May 25, 2006, in forum: C Programming
    Replies:
    8
    Views:
    742
    those who know me have no need of my name
    May 28, 2006
  2. Replies:
    5
    Views:
    366
    Fredrik Lundh
    Aug 29, 2008
  3. Derek Martin
    Replies:
    3
    Views:
    259
    Derek Martin
    Aug 29, 2008
  4. Long Li
    Replies:
    2
    Views:
    91
    J├╝rgen Exner
    Dec 29, 2003
  5. Bart Vandewoestyne
    Replies:
    8
    Views:
    744
    Bart Vandewoestyne
    Sep 25, 2012
Loading...

Share This Page