473,288 Members | 1,750 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,288 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 1311
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: 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:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
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: 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...
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)...

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.