Re: How to delete a last character from a string

2008-08-29 Thread Derek Martin
On Fri, Aug 29, 2008 at 07:37:50PM +, Steven D'Aprano wrote: > On Fri, 29 Aug 2008 14:46:53 -0400, Derek Martin wrote: > > > On Fri, Aug 29, 2008 at 07:28:40PM +0100, [EMAIL PROTECTED] wrote: > >> dirListFinal = [] > >> for item in dirList: > >>print item > >>if item.en

Re: How to delete a last character from a string

2008-08-29 Thread dudeja . rajat
On Fri, Aug 29, 2008 at 8:37 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 29 Aug 2008 14:46:53 -0400, Derek Martin wrote: > >> On Fri, Aug 29, 2008 at 07:28:40PM +0100, [EMAIL PROTECTED] wrote: >>> dirListFinal = [] >>> for item in dirList: >>>print item >>>if it

Re: How to delete a last character from a string

2008-08-29 Thread Steven D'Aprano
On Fri, 29 Aug 2008 14:46:53 -0400, Derek Martin wrote: > On Fri, Aug 29, 2008 at 07:28:40PM +0100, [EMAIL PROTECTED] wrote: >> dirListFinal = [] >> for item in dirList: >>print item >>if item.endswith('\\') == True: > > if item[-1] == '\\': Which will fail b

Re: How to delete a last character from a string

2008-08-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: There is just a single \ at the end of every item. My list is as below: ['Results v1.0/', 'Results v1.1/'] so, if x.endswith('\\'): is that correct? if your list contains forward slashes, maybe you should test for forward slashes and not backward slashes. -- ht

Re: How to delete a last character from a string

2008-08-29 Thread dudeja . rajat
On Fri, Aug 29, 2008 at 7:59 PM, <[EMAIL PROTECTED]> wrote: > On Fri, Aug 29, 2008 at 7:41 PM, Mike Driscoll <[EMAIL PROTECTED]> wrote: >> On Aug 29, 1:28 pm, [EMAIL PROTECTED] wrote: >>> Sorry : Earlier mail had a typo in Subject line which might look >>> in-appropriate to my friends >>> >>> Hi,

Re: How to delete a last character from a string

2008-08-29 Thread dudeja . rajat
On Fri, Aug 29, 2008 at 7:41 PM, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Aug 29, 1:28 pm, [EMAIL PROTECTED] wrote: >> Sorry : Earlier mail had a typo in Subject line which might look >> in-appropriate to my friends >> >> Hi, >> >> I've a list some of whose elements with character \. >> I want

Re: How to delete a last character from a string

2008-08-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: 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: pr

Re: How to delete a last character from a string

2008-08-29 Thread Derek Martin
On Fri, Aug 29, 2008 at 07:28:40PM +0100, [EMAIL PROTECTED] wrote: > dirListFinal = [] > for item in dirList: >print item >if item.endswith('\\') == True: if item[-1] == '\\': -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D pgp5fVWPp4A

Re: How to delete a last character from a string

2008-08-29 Thread Mike Driscoll
On Aug 29, 1:28 pm, [EMAIL PROTECTED] wrote: > Sorry : Earlier mail had a typo in Subject line which might look > in-appropriate to my friends > > 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

Re: How to delete a last character from a string

2008-08-29 Thread Mike Kent
On Aug 29, 2:28 pm, [EMAIL PROTECTED] wrote: > Sorry : Earlier mail had a typo in Subject line which might look > in-appropriate to my friends > > 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

How to delete a last character from a string

2008-08-29 Thread dudeja . rajat
Sorry : Earlier mail had a typo in Subject line which might look in-appropriate to my friends 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