473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to delete a ast character from a string?

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 '08 #1
0 773

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Randy Gordon | last post by:
Say I do the following: char **names = new char*; for (int i = 0; i < 100; i++) { names = new char; } When I'm done with the array of character pointers, how should I delete it? Like this:
5
by: Raj | last post by:
Hi all, Can anyone help me with a script which would delete files or move them to a different folder at some scheduled time..! Please.....!!! Thanks in advance...
8
by: Michael R. Copeland | last post by:
What is a good way to delete 1 character (or several) from a character array that's being processed as a "string"? Specifically, I have something like: char szWork; .... strcpy(szWork,...
3
by: ozbear | last post by:
The title says it all. Since a Richedit control doesn't understand a backspace character ('\b', or 0x08) when I receive one I need to programmatically delete the last character from the Richedit...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
5
by: michael | last post by:
Hi All, I have the following: const int LENGTH = 5; void limitNameLength(string inText, char *&outText, int outLength){ if(static_cast<int>(inText.length()) outLength){ inText =...
1
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
5
by: dudeja.rajat | last post by:
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...
0
by: dudeja.rajat | last post by:
On Fri, Aug 29, 2008 at 7:40 PM, Chris Rebert <cvrebert+clp@gmail.comwrote: Thanks for the suggestions. I wondered if the item is really a string. So I added the following to check this: ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.