IdentationError; unexpected indent

Ian Kelly ian.g.kelly at gmail.com
Wed Apr 13 12:05:50 EDT 2016


On Wed, Apr 13, 2016 at 9:53 AM, salma ammar <ammarsalma118 at gmail.com> wrote:
> Hi,
>
> I am about to run this code using python 2.7. But when executing this code,
> an error appears (see attachement): IdentationError; unexpected indent
>
> What should I rectify to correct this error please?

First of all, please post your code exactly as you're trying to run
it. All those asterisks make it harder to read and also create doubts
about what other changes might have been introduced in the process of
being posted.

Second, read the error message. It tells you what the problem is:
unexpected indent. It should also tell you exactly line the error
occurs on, but you didn't include that part of the error message in
your post, so we can't help you there. Next time, please post the
entire error message, including the traceback.

> *  edges = net.getNeighboringEdges(x, y, radius)*
> * distancesAndEdges = sorted([(dist, edge) for edge, dist in edges])*
> *  print(distancesAndEdges)*
> *        edgeofstation[id] = distancesAndEdges[0]*
> *        print (edgeofstation[id])*

That said, these five lines all appear to have inconsistent
indentation with the preceding. I don't know what the intent was, but
you should correct the indentation of these lines.



More information about the Python-list mailing list