GoConqr has a new look! Let us know what you think.

Module 22 of 23 · Text

How to spoil and fix your code 3

David Khieu

How to spoil and fix your code 3

You may have noticed that the error message generated for the previous error is quite different from the first one. 

This is because the nature of the error is different and the error is discovered at a different stage of interpretation. 

The Editor window will not provide any useful information regarding the error, but the console windows might. 

The message (in red) shows (in the subsequent lines): 

  • the traceback (which is the path that the code traverses through the different parts of the program - you can ignore it for now, as it is empty in such a simple code)
  • the location of the error (the name of the file containing the error, line number and module name); note: the number may be misleading, as Python usually shows the place where it first notices the effects of the error, not necessarily the error itself.
  • the content of the erroneous line; note: IDLE's editor winow doesn't show line numbers, but it displays the current cursor location at the bottom-right corner; use it to locate the erroneous line ina  long source code
  • the name of the error and a short explanation

Experiment with creating new files and running your code. Try to output a different message to the screen, e.g. roar!, meow, or even oink!, Try to spoil and fix your code - see what happens. 

 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?