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

Re: Typeerror


This is a simple error, you are passing the variable res as an interger to
use for a slice when what ever you are storing in res isn't an integer.

Chris

Beema shafreen wrote:
>
Hi all,
I getting the following error when i run my scirpt ,
can somebody help me regarding this to solve the type error problem
Traceback (most recent call last):
File "get_one_prt_pep.py", line 59, in ?
if len(data[res])<=1:
TypeError: string indices must be integers
--
Beema Shafreen

--
http://mail.python.org/mailman/listinfo/python-list
--
View this message in context: http://www.nabble.com/Typeerror-tp17...p17358932.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Jun 27 '08 #1
1 1318
On May 21, 9:58*am, Freaky Chris <angry-ch...@hotmail.comwrote:
This is a simple error, you are passing the variable res as an interger to
use for a slice when what ever you are storing in res isn't an integer.

Chris

Beema shafreen wrote:
Hi all,
I getting the following error when i run my scirpt ,
can somebody help me regarding this to solve the type error problem
Traceback (most recent call last):
* File "get_one_prt_pep.py", line 59, in ?
* * if len(data[res])<=1:
TypeError: string indices must be integers
--
Beema Shafreen
--
http://mail.python.org/mailman/listinfo/python-list

--
View this message in context:http://www.nabble.com/Typeerror-tp17...p17358932.html
Sent from the Python - python-list mailing list archive at Nabble.com.
If it is an integer, but stored as a string you can use:

if len(data[int(res)])<=1

its not pretty but it should sort out the type errors
Jun 27 '08 #2

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

Similar topics

3
by: Achim Domma | last post by:
Hi, I'm using MySQLdb with Python 2.3 on windows. Querying a database seems to work fine, but inserting does not. If I try something like this: cursor.execute("insert into Webpages (Url)...
0
by: Michael Spencer | last post by:
Using: Python 2.3.3 Tkinter.TclVersion = 8.4000000000000004 Windows XP Calling edit_modified() on a Tkinter.Text object raises TypeError when it gets a Boolean True response. Exception in...
2
by: Thorsten Kampe | last post by:
What is the best way to except two errors, when the except handling in both cases is the same? "except:" would just except every error and not just those I want. except Attribute error:...
2
by: Balaji | last post by:
Hello Everybody... I have a problem.. This is the code... -------------------------------------- class Stack: def __init__(self,expr): self.stackP=
7
by: ‘5ÛHH575-UAZWKVVP-7H2H48V3 | last post by:
(see end of message for example code) When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message "TypeError: instancemethod expected at least 2...
1
by: Paul Du Bois | last post by:
Using win32 python 2.4.1, I have a minimal test program: def generate(): raise TypeError('blah') yield "" print "\n".join((generate())) Executing the program gives:
7
by: Girish Sahani | last post by:
Hi, Please check out the following loop,here indexList1 and indexList2 are a list of numbers. for index1 in indexList1: for index2 in indexList2: if ti1 == ti2 and not index1 !=...
8
by: digitalorganics | last post by:
What are the reason one would get this error: TypeError: Cannot create a consistent method resolution order (MRO) for bases object ?? I can provide the code if needed....
10
by: est | last post by:
>>import md5 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python25\lib\pickle.py", line 1366, in dumps Pickler(file, protocol).dump(obj) File...
0
by: James Mills | last post by:
On Fri, Oct 31, 2008 at 8:49 AM, mark floyd <emfloyd2@gmail.comwrote: Mark, this is correct behavior. You have 3 positional arguments in the function definition. You _must_ aupply _all_ 3 of...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.