Error messages and what they mean

This page describes a number of Python error messages and what they mean.

Is yours missing? Add it yourself, or|szp#em liam about it.

Incorrect operand

Incorrect operand types for /: sequence and integer

This indicates that the types of variables or literals passed to the operator mentioned are not appropriate. An "operand" refers to the thing passed to an operator. In this case, the operator "/" cannot operate on a sequence and an integer.

Essentially what this is saying is that you cannot divide a sequence (like a string) by an integer - it just doesn't make sense. In Physics or maths, you sometimes say "you can't add apples to oranges" to indicate that the units in an equation must make sense. You can't add metres to seconds, for example. However you can divide metres by seconds to get velocity - whether an operation makes sense depends both on the operators and the operands. This principle applies in exactly the same way in programming.


IndentationError: unindent does not match any outer indentation level

A problem with the indenting of your program.


NameError: name 'greetign' is not defined

The name referred to in the code is not one that Python recognises as a keyword or variable name. There are some common causes of this problem.

Exception in Tkinter callback

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python25\lib\lib-tk\", line 1403, in __call__
    return self.func(*args)
  File "C:\Python25\lib\idlelib\", line 151, in handler
    r = l[i](event)
  File "C:\Python25\lib\idlelib\", line 168, in run_module_event
  File "C:\Python25\lib\idlelib\", line 701, in runcode
AttributeError: ModifiedInterpreter instance has no attribute 'interp'

This error occurs when you run a program using the Canvas library (used from Unit 2 onwards) more than once. This is a known problem with Canvas, and is not caused by your programming. The only solution is to close all Python windows then re-run IDLE after each time you run your program.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License