Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

How to spoil and fix your code 2

Watch all the windows carefully. 

 A new window appears - it says that the interpreter has encountered an EOF (end-of-file) although (in its opinion) the code should contains some more text. 

The editor window shows clearly where it happened. 

Fix the code now. It should look like this: 

print("Hissssss...")

Run it to see if it "hisses" again. 

Let's spoil the code one more time. Remove one letter from the word print Run the code by pressing F5. What happens now? As you can see, Python is not able to recognize the instruction. 

 

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.