Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Connor Niblett
Connor Niblett
675 Points

Why do error logs not specify the line where the error is actually present?

At 6:39 in the video the instructor explains that the indentation error is actually present on line 9. However, the error code the console provides specifies the error is on line ten. I was wondering why the console would incorrectly identify the position of the error?

2 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Data Analysis Techdegree Graduate 49,443 Points

Hey Connor Niblett ! :wave:

So this happens due to the way the Python interpreter parses and processes the code. It reads it line by line and will hold off on declaring an error until it can confirm that there's an indentation error. Usually it's not until it has passed the line to see what was next.

I seem to get pretty accurate error messages most of the time though regarding the line in my text editors, but if you do see one and it doesn't quite look right, I would look up a line or two and double check those just in case.

Connor Niblett
Connor Niblett
675 Points

For clarity I was referencing the comparisons video in the Python basics course, types and branching chapter.