473,240 Members | 1,632 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,240 software developers and data experts.

Delete values from a string using the index

How do I delete or remove values from a list or string using the
index.

If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would I do
that?

Thanks.

Sep 26 '07 #1
6 4906
ko****@hotmail.com wrote:
How do I delete or remove values from a list or string using the
index.

If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would
I do that?
del a[0:5]

Be sure to check out the relevant section of the Python tutorial.

http://docs.python.org/tut/node7.html

Regards,
Björn

--
BOFH excuse #31:

cellular telephone interference

Sep 26 '07 #2
ko****@hotmail.com wrote:
How do I delete or remove values from a list or string using the
index.

If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would I do
that?

Thanks.
del a[1]
del a[-5]

Sep 26 '07 #3
On Sep 26, 2007, at 3:25 PM, ko****@hotmail.com wrote:
How do I delete or remove values from a list or string using the
index.

If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would I do
that?

Thanks.

--
http://mail.python.org/mailman/listinfo/python-list
>>l = [1, 2, 3]
del l[1]
l
[1, 3]

Erik Jones

Software Developer | Emma®
er**@myemma.com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com
Sep 26 '07 #4
ko****@hotmail.com wrote:
How do I delete or remove values from a list or string using the
index.

If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would I do
that?

Thanks.
If you want to do it all at once :

del a[1:4:2]
Sep 26 '07 #5
ko****@hotmail.com a écrit :
How do I delete or remove values from a list
del
or string
You can't. Python's strings are immutables.
using the
index.

If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would I do
that?
del a[0:5]
print a

Sep 27 '07 #6
In message <11*********************@y42g2000hsy.googlegroups. com>,
ko****@hotmail.com wrote:
How do I delete or remove values from a list or string using the
index.
Note you can't do it with a string, since that's not mutable.
Sep 27 '07 #7

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

Similar topics

5
by: Sid | last post by:
Hi, I was going through this reference code and playing around with it. The code (shown below) shows a class that represents a stack of string pointers In the code below in particular in the...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: memosa | last post by:
Hi, friends: This is my programme (work on Microsoft visual c++) and I have two question . First, I want to say that there is no error but I need a little help. This is a small programme...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
0
by: David C | last post by:
I have a GridView with a Delete link and wondered where the best place was to check and cancel delete of a row/record that is bound to an SqlDatasource. I can use datasource Deleting event or...
7
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
2
by: William LaMartin | last post by:
On webform, I am populating a GridView from a SQLDatasource based on a MySQL table named PIB. There is no vb code involved. Everything is done in the source for the aspx page, provided below. ...
8
by: chromis | last post by:
Hi, I'm writing a contacts section for a cms on a website, I've decided to write the section in OO code. So far I have my Contacts object and a page structure I would use for a procedural site. ...
8
by: Michel Esber | last post by:
Hello, Env: DB2 V8 LUW FP16 running Linux create Table X (machine_id varchar(24) not null, ctime timestamp not null); create index iFoo on X (MACHINE_ID, CTIME) allow reverse scans; alter...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...

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.