[python error] Indexerror list index out of range

‘list index out of range’ most likely means you are referring to n-th element of the list, while the length of the list is smaller than n.

Using range for iteration is nearly always not the best way. In Python you can iterate directly over a list, dict, set etc.:

for item in d.entries:
    updates.append([{"url": feed_a_enviar["linktoourpage"], "msg": item.title + ", "}])

Obviously d.entries[i] triggers the error because that list contains less than 8 items (feeds_updatesmay contain 8, but you are not iterating over that list).

1) Python’s default behavior for chained comparisons don’t work as you’d expect for numpy arrays.
2) Python doesn’t allow numpy to change this default behavior (at least currently, and maybe never).

Indentationerror unexpected indent

Python uses spacing at the start of the line to determine when code blocks start and end. Errors you can get are:

Unexpected indent. This line of code has more spaces at the start than the one before, but the one before is not the start of a subblock (e.g. if/while/for statement). All lines of code in a block must start with exactly the same string of whitespace. For instance:

>>> def a():
...   print "foo"
...     print "bar"
IndentationError: unexpected indent
“each line within a basic block must be indented by the same amount“. (Wrong use of the term “basic block”, [this python doc]
1) Make sure your lines are indented properly, remembering that Python thinks that tab stops are every 8 columns.
2) Look for a missing colon on the line above, which is usually a forifelsewhiletry, or similar type of line. In general, if a line ends in a colon, the next line with code needs to be indented by some amount.
3)using the -tt‘ command-line option to determine when you accidentally mix tabs and spaces.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......







Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision


Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness



Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: