Some mistakes students commonly make
- Say data is a list. When you write for r in data:, r is a reference to the contents of data. You cannot use r to index the list, like data[r].
- If you want to use r to index the list data, use the construct for r in range(len(data)) .Now r assumes values in the range 0..len(data)-1.
- ^ is not the exponentiation operator in Python. ^ is the bitwise xor (exclusive or) operator. Evaluate 3^2 in the interpreter to see what it does.
- Variables referenced as self.variableName are instance variables in a Python class, and have class-wide scope. If you leave out the self, variableName by itself is merely a local variable within the method.