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

How to get a substring with variable indices

Hello all!

I have a string named text. I need to extract a substring from it
starting by variable 's' and ending by 'e'.

text[s:e] generates the following error:

TypeError: slice indices must be integers or None
How to be? :)

Regards, Stanislav Yaglo.
Dec 18 '06 #1
1 1989
ÁâÐÝØáÛÐÒ ÏÓÛÞ <st**@legche.netwrites:
text[s:e] generates the following error:
TypeError: slice indices must be integers or None

How to be? :)
s and e both have to be integers or None. Try printing them out just
before your slice to see if their values are reasonable.
>>s = 2
e = 4
"python"[s:e]
'th'
Dec 18 '06 #2

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

Similar topics

11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
1
by: Nico Grubert | last post by:
Hi there, I would like to search for a substring in a string and get the index of all occurances. mystring = 'John has a really nice powerbook.' substr = ' ' # space I would like to get...
4
by: Jean-François Michaud | last post by:
Hello, I've been looking at this for a bit now and I don't see what's wrong with the code. Can anybody see a problem with this? Here is an XSLT snippet I use. <xsl:template match="graphic">...
2
by: Daniel Reardon | last post by:
All, I'm sure that this is an old question, but I'm having problems getting a substring of a passed in variable. I can do other string manipulation with it such as concatonation, but I'm really...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.