While executing programs with large lists ,i am encountering an error message:
Index error:List index out of range
The program works well with small lists..Can anyone suggest me some efficient methods to handle this problem?or Is there any other efficient datastructure other than lists and dictionary to serve the purpose ?

you could split your list in to 2 smaller lists and process them indervidualy.

Also you may wish to look into vectors

Chris

I don't think it has much to do with the size of the list, you are simply going past the number of indexed elements. Look at this example:

my_list = [1, 2, 3, 4]
print my_list[4]  # IndexError: list index out of range

that is what i was thinking, but i was also thinking that it works fine for shorter lists, so i was guessing he wouldn't actual do that

Chris

"list index out of range" has nothing to do with the size of the list AFAIK. If the list were too large there would be some sort of out of memory message.

Is there any other efficient datastructure other than lists and dictionary to serve the purpose ?

SQLite can be used in memory but you'll have to provide some more info on how many records you want to store, what is the size of each record, and what you want to do in order to be more specific.

Member Avatar for kdoiron

I have to agree with EneUran - the size of the list is, or at least should be, irrelevant.

Athirar, can you post a code sample and your list?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.