if unit == 'F': self.number = (number - 32) * 5/9 UnboundLocalError: local variable 'number' referenced before assignment
number variable need to be declare first at the beginning of to() function. A simple : " number; " in first line of your to() function will solve the problem.