0

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 ?

5
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by kdoiron
0

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

Also you may wish to look into vectors

Chris

0

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
0

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

0

"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.

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.