473,321 Members | 1,916 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,321 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 4917
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: 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: 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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
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
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.